Jumping on Walls CodeForces - 198B】的更多相关文章

Jumping on Walls CodeForces - 198B 应该是一个隐式图的bfs,或者叫dp. 先是一个TLE的O(nklogn) #include<cstdio> #include<set> using namespace std; typedef pair<bool,int> P; ]; P t; ][]; int n,k,ii; int main() { int i,num,hei; scanf("%d%d",&n,&am…
题目:http://codeforces.com/problemset/problem/198/B Jumping on Walls time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya plays a computer game with ninjas. At this stage Vasya's ninja shou…
大意: 给定格点图, 每个'.'的连通块会扩散为矩形, 求最后图案. 一开始想得是直接并查集合并然后差分, 但实际上是不对的, 这个数据就可以hack掉. 3 3 **. .** ... 正解是bfs, 一个点被扩散当且仅当它所在的某个2*2块中只有它为'*'. #include <iostream> #include <iostream> #include <algorithm> #include <cstdio> #include <math.h&…
A. Hexadecimal's theorem 三个数没有限制,直接输出\(0\ 0\ n\). B. Special Olympics 分包含和外离情况,包含分2种情况. C. About Bacteria 考虑1个细菌需要多少时间增长到\(t\),扣掉即可. D. Jumping on Walls bfs. E. Delivering Carcinogen 题目保证\(v \gt v_p\),所以到达时间具有单调性. 二分到达时间,那么此时星球的位置已经固定,问题转化成考虑两个固定点在不穿…
D. Fox And Jumping 题目连接: http://codeforces.com/contest/510/problem/D Description Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at…
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple t…
B. Jumping Jack 题目连接: http://www.codeforces.com/contest/11/problem/B Description Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has d…
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/D Description Finally it is a day when Arthur has enough money for buying an apartment. H…
D - MUH and Cube Walls Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 471D Description Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo o…
题目传送门 /* 题意:问最少替换'*'为'.',使得'.'连通的都是矩形 BFS:搜索想法很奇妙,先把'.'的入队,然后对于每个'.'八个方向寻找 在2*2的方格里,若只有一个是'*',那么它一定要被替换掉 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <queue> using namespace std; ;…
传送门 D. Arthur and Walls time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Finally it is a day when Arthur has enough money for buying an apartment. He found a great option close to the cente…
Jumping Jack CodeForces - 11B 就是一个贪心. 基本思路: 正负没有关系,先取绝对值. 首先跳过头,然后考虑怎么回来. 设超过头的步数为kk.如果kk为偶数,那么直接在前面跳过来的步数中选一个kk/2的步数,改成反着跳即可,不需要额外步数. 如果kk为奇数: 显然如果只把前面跳的改成反着跳不可能导致位置与目标位置差值的奇偶性变化,而kk为奇数,需要达到的差值0是偶数,因此一定需要额外步数. 那么可能有两种情况: 设当前已经跳了p步.如果p为偶数,那么这一步的下一步(p…
B. Fox And Jumping time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negativ…
B. Jumping Jack Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and each subsequen…
D. Arthur and Walls time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Finally it is a day when Arthur has enough money for buying an apartment. He found a great option close to the center of…
http://codeforces.com/contest/1077/problem/A A frog is currently at the point 00 on a coordinate axis OxOx. It jumps by the following algorithm: the first jump is aa units to the right, the second jump is bb units to the left, the third jump is aa un…
D. MUH and Cube Walls 说实话,这题看懂题意后秒出思路,和顺波说了一下是KMP,后来过了一会确定了思路他开始写我中途接了个电话,回来kaungbin模板一板子上去直接A了. 题意:有两座城堡,每座城堡有一定的形状分别由高度区分.求第一座城堡中有多少个区间的形状和第二座城堡相似.连续一段区间高度可以任意变,但他们的相对位置是不变的. 思路:基于一段连续区间无论怎么变他们的相对位置不会变,所以分别将两个序列相邻的元素作差,一段区间的相对位置不会变,所以正好可以用差值去匹配.所以K…
[题目链接]:http://codeforces.com/contest/510/problem/D [题意] 你可以买n种卡片; 每种卡片的花费对应c[i]; 当你拥有了第i种卡片之后; 你可以在任意位置x跳到x-l[i]或x+r[i]; 问你至少要花费多少钱买卡片,使得你能够跳跃到坐标轴上的任意一个整数点; [题解] 有个结论: 直接记下来吧 如果gcd(a,b)==1,那么所有的点就都能跳跃到了; 所以问题就转化为,给你n个长度,让你在这n个长度中选取若干个; 使得它们的gcd为1; 且要…
B. Jumping Jack time limit per test 1 second memory limit per test 64 megabytes input standard input output standard output Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get…
C. Platforms Jumping There is a river of width n. The left bank of the river is cell 0 and the right bank is cell n+1 (more formally, the river can be represented as a sequence of n+2 cells numbered from 0 to n+1). There are also m wooden platforms o…
Time limit         2000 ms  Memory limit  262144 kB Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cu…
There is a river of width nn. The left bank of the river is cell 00 and the right bank is cell n+1n+1 (more formally, the river can be represented as a sequence of n+2n+2 cells numbered from 00 to n+1n+1). There are also mm wooden platforms on a rive…
Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and each subsequent jump will be e…
题意:给定两个序列a ,b, 如果在a中存在一段连续的序列使得 a[i]-b[0]==k, a[i+1]-b[1]==k.... a[i+n-1]-b[n-1]==k 就说b串在a串中出现过!最后输出b串在a串中出现几次! 思路: KMP变形!如何转换成KMP求解呢? 举一个例子说明一下: a: 5 10 8 10 11 9 11 12 10 15 b: 4 2 4 5 3 根据题意 a中的 10 8 10 11 9 与 b是匹配的, 11 9 11 12 10跟b也是匹配的! 如何将b串以及…
广搜.看了官方题解才会的..... 定义2*2的小矩阵,有三个是点,一个是星,这样的小矩阵被称为元素块. 首先把所有元素块压入队列,每次取出对头,检查是否还是元素块,如果是 那么将那个*改为点,否则跳过 改完之后,检查周围8个点是否是元素块,如果有新产生的元素块,那么压入队列. 这样操作完之后就是答案. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include&l…
这题说的是给了一个矩阵,必须让.连接起来的图形变成矩形,2000*2000的矩形,那么我们就可以知道了,只要是存在一个有点的区域应该尽量将他削为矩形,那么将这个图形进行缩放,最后我们知道只要存在一个2*2 的矩形中有1个是*就必须将这个*号去掉. 采用bfs去做 #include <iostream> #include <algorithm> #include <string.h> #include <cstdio> #include <queue&g…
题目大意 Description 给你一个字符集合,你从其中找出一些字符串出来. 希望你找出来的这些字符串的最长公共前缀*字符串的总个数最大化. Input 第一行给出数字N.N在[2,1000000] 下面N行描述这些字符串,长度不超过20000 .保证输入文件不超过10MB Output 输出一行一个整数代表字符串的最长公共前缀*字符串的总个数的最大值. Sample Input 7 Jora de Sus Orhei Jora de Mijloc Joreni Jora de Jos Ja…
题目链接 题意说的是,有n种卡片,使用第i种卡片可以使当前自己在数轴上的位置移动 l[i],要获得使用第i种卡片的代价是 c[i],求能使自己移动到数轴上任意位置的最小代价,如果不可能则输出-1 当前所拥有的卡片由1->n,逐渐调整map里的值 #include<bits/stdc++.h> using namespace std; ; int n; int c[N],l[N]; map<int,int> dp; int gcd(int a,int b) { return b…
题目链接: http://codeforces.com/contest/724 A. Checking the Calendar time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given names of two days of the week. Please, determine whether it is…
Lemmings 题目连接: http://codeforces.com/contest/163/problem/B Descriptionww.co As you know, lemmings like jumping. For the next spectacular group jump n lemmings gathered near a high rock with k comfortable ledges on it. The first ledge is situated at t…