CodeForces
sunlanchang
北京邮电大学-计算机硕士,sunlanchang@bupt.edu.cn
展开
-
CodeForces 699 A. Launch of Collider(水)
Description 坐标轴上有n个粒子,粒子坐标均为偶数,每个粒子有一个运动方向(向左或向右),速度均为1,问粒子相碰撞的最早时间,如果没有粒子会相碰则输出-1 Input 第一行一个整数n表示粒子个数,第二行n个字符(R or L)表示每个粒子的运动方向,第三行n个整数表示每个粒子的坐标xi(1<=n<=200000,0<=xi<=10^9) Output 输出粒子相碰撞的原创 2017-07-31 17:44:46 · 251 阅读 · 0 评论 -
CodeForces - 793B Igor and his way to work (BFS转弯问题)
description有一座 n 行 m 列的城市。 Igor 需要找到一条从他家到单位的路径,最多转两次弯。Igor只能向左向右或是向上向下走。城市中有一些障碍,现在问你Igor是否能找到这样一条路径。Input第一行包含两个整数 n 和 m (1 ≤ n, m ≤ 1000) — 表示城市的行列数之后 n 行每行包含 m 个字符,每个字符的含义如下:“.” — 一个空格...原创 2018-03-27 17:15:55 · 288 阅读 · 0 评论 -
Codeforces 520B. Two Buttons(隐式BFS)
description给定两个数字m、n,和两种操作分别是乘2、减1。从n变化到m最少需要多少步。变化的过程中不能出现负数。Inputm和n的范围 (1 ≤ n, m ≤ 10^4),Output输出最少需要多少步input4 6output2input10 1output9solution隐式的BFS,注意...原创 2018-03-25 23:03:45 · 306 阅读 · 0 评论 -
CodeForces - 616C The Labyrinth (优化BFS)
description输入n*m的方格,有和.组成,输出n*m的矩阵,如果str[i][j] = ‘.’直接输出’.’,如果str[i][j] = ‘‘,则假设str[i][j]=’.’,上下左右四个方向相连的’.’的个数Examplesinput3 3 . .*. .output3.3 .5. 3.3input4 5 *.. ..* ...原创 2018-03-25 15:17:52 · 272 阅读 · 0 评论 -
CF-3A Shortest path of the king(water)
description给定棋盘中的两个位置,给出行走的最短路径,一个棋子的八个方向均可以行走。方向分别是L,R,U,D,LU,LD,RU,RD。inputa8 h1output7 RD RD RD RD RD RD RDp1, p2 = input(), input()x1, y1 = ord(p1[0]) - ord('a') + 1, int(原创 2018-02-04 20:14:31 · 228 阅读 · 0 评论 -
CF-2A Winner(water)
description输入名字和点数,如果名字重复则点数累加,点数可以为负数,计算点数最大者,如果点数相同则最先达到最大点数的为最大者。input包含一个整数n(13 mike 3 andrew 5 mike 2 3 andrew 3 andrew 2 mike 5outputandrew andrewsolution使用字典累加,用列表保存状态即可原创 2018-02-02 19:21:46 · 301 阅读 · 0 评论 -
CF-1B Spreadsheets(water)
description给定整数n (1<=n<=105)" role="presentation">(1=n=105)(1n105)(1 接下来是n组测试用例,测试用例有两种格式,第一种由R代表行号,C代表列号,将这种形式转换为26进制,并且第一个数字为A,类似与Excel表格命名方法。input2 R23C55 BC23ouputBC23 R23C55s原创 2018-02-01 22:22:30 · 224 阅读 · 0 评论 -
CF 851A Arpa and a research in Mexican wave
Discription有n个观众,第一时刻第一个观众站起来,第二时刻第二个观众站起来….第k时刻第k个观众站起来,第k+1时刻第k+1个观众站起来并且第一个观众坐下……第n+1时刻,第n+1-k个观众坐下,直到d+k时刻,第n个观众坐下,求第t时刻站着。Inputn, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).Outputt时刻站着的人Examples原创 2017-09-05 20:26:04 · 340 阅读 · 0 评论 -
LeetCode 667. Beautiful Arrangement II
Discription给定两个整数n和k,构建一个n个元素数组,数组要满足一下要求: 假设数组[a1,a2....an]那么[|a2-a1|,|a3-a2|.....]包含k个不同的整数。如果有多个数组输出任意一个数组。1<=k<n<=10000。ExampleInput: n = 3, k = 1 Output: [1, 2, 3] Input: n = 3, k = 2 Output:原创 2017-08-27 16:39:35 · 1672 阅读 · 3 评论 -
CF 839A - Arya and Bran(水)
Discription给定n天,每天有a[i]个蛋糕。小明一共需要k个蛋糕,每天给小明的蛋糕数量<=8,如果今天给了小明8个蛋糕后有剩余,可以将剩余的蛋糕积攒到明天,以此类推,问小明最少几天能得到k个蛋糕。InputThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 10000). The second line c原创 2017-08-13 11:38:19 · 313 阅读 · 0 评论 -
CF 779A A. Pupils Redistribution (水)
In Berland each high school student is characterized by academic performance — integer value between 1 and 5.In high school 0xFF there are two groups of pupils: the group A and the group B. Each group原创 2017-07-18 17:02:11 · 338 阅读 · 0 评论 -
CodeForces 4 A.Watermelon(水)
Description 一个体积为w的西瓜,能否分成两半使得体积均为偶数 Input 一个整数w表示西瓜体积(1<=w<=100) Output 如果可以分成体积均为偶数的两块则输出YES,否则输出NO Sample Input 8 Sample Output YES Solution 水题,奇数和2不行,其他都行 Code#include <iost原创 2017-07-31 17:46:08 · 525 阅读 · 0 评论 -
剑指 offer 树的子结构
题目描述输入两棵二叉树A,B,判断B是不是A的子结构。(ps:我们约定空树不是任意一个树的子结构)Solution注意分析时将树画出None节点以便于分析和测试。class Solution: def HasSubtree(self, pRoot1, pRoot2): result = False if pRoot1 is not None and...原创 2019-08-16 15:44:42 · 150 阅读 · 0 评论