Codeforces 1169A Circle Metro】的更多相关文章

题目链接:codeforces.com/contest/1169/problem/A 题意:有俩个地铁,一个从 1 → 2 → …→ n → 1→ 2 →…, 一个 从 n → n-1 →…→ 1 → n → n-1→ ….地铁同时开并且地铁经过一个站的时间都相同,俩个人一个坐前面那俩,一个坐后面那俩,给你他们的起点站和终点站,问他们在这过程中有没有可能同时在一个站,可能就输出YES,否则输出NO. 思路:一个 i 从 起始 a 开始加 ,一个 j 从 b 开始减,如果 i 加到 n+1 就让它…
链接:https://codeforces.com/contest/1169/problem/A 题意: The circle line of the Roflanpolis subway has nn stations. There are two parallel routes in the subway. The first one visits stations in order 1→2→…→n→1→2→…1→2→…→n→1→2→… (so the next stop after sta…
目录 @description@ @solution@ @accepted code@ @details@ @description@ 环上有 n 个点,按顺时针顺序以 1 到 n 编号.其中 1~m 号点是红色的,m+1~n 号点时蓝色的. 一开始你位于点 s,并给定一个 t. 你需要重复以下步骤,直到 t = 0: 如果你所在结点为红色,顺时针移动 t 个点:否则逆时针移动 t 个点.然后 t 减一. 求最终所在的结点编号. Input 第一行包含两个整数 n 和 m (3≤n≤10^5,…
A - Circle Metro 模拟几百步就可以了. B - Pairs 爆搜一下,时间复杂度大概是 $O(4 * n)$ Code: 56306723 C - Increasing by Modulo 二分答案,然后验证一下就好了,第一个数越小越好,之后的数都要求和前一个相等或者大一点.复杂度 $n * log(n)$ D - Good Triple 对于每一个 $i$,需要计算出最小的 $x$,使得 $s[i-x] = s[x] = s[i + x]$,对于 $i$ 而言,如果区间左端点在…
题目连接:652F - Ants on a Circle 题目大意:\(n\)个蚂蚁在一个大小为\(m\)的圆上,每个蚂蚁有他的初始位置及初始面向,每个单位时间蚂蚁会朝着当前面向移动一个单位长度,在遇到其它蚂蚁时会立刻掉头.求经过\(t\)个单位时间后每一个蚂蚁的所在位置 题解:首先可以发现,最终答案其实是在不考虑碰撞下得出答案的一个排列,而且蚂蚁们的相对位置是不会改变的.所以如果求出了其中任意一个蚂蚁的位置,就能求出最终的答案. 为了方便起见,先默认所有蚂蚁的位置是按升序排的,且第一个蚂蚁的位…
Ants on a Circle 感觉这个思路好巧妙啊. 我们能发现不管怎么碰撞,初始态和最终态蚂蚁间的相对顺序都是一样的, 并且所占的格子也是一样的, 那么我们就只需要 找到其中一个蚂蚁的最终位置就能确定所有蚂蚁的位置了, 我们考虑找初始为止离0最近的那个蚂蚁的最终位置,我们能发现 蚂蚁从m-1->0  rk++, 蚂蚁从0->m-1 rk--, 在取模意义下rk就是那个蚂蚁的最终位置. #include<bits/stdc++.h> #define LL long long #…
F. Maximum Balanced Circle 题目链接 题意 给出\(n\)个数,现在要从中选出最多的数\(b_i,b_{i+1},\cdots,b_k\),将这些数连成一个环,要求两两相邻的数相差不超过1. 最后要求输出具体的方案. 题解 一开始想了一个dp,似乎也可以做 这个题也不用这么复杂,因为相差绝对值不超过1,直接统计一下每个数的个数就行了. 因为如果将最后的环给展开,以每个数的值为高,呈现出来的图形一定是先上升后下降的.那么中间部分的数的个数一定大于等于2,最左边和最右边的两…
题目链接:http://codeforces.com/problemset/problem/1189/B AC代码: #include<bits/stdc++.h> using namespace std; ; int a[maxn]; int b[maxn]; int c[maxn]; bool check(int i) { ]+a[i+]) return true; else return false; } int main() { int n; cin >> n; ;i &l…
D. Nauuo and Circle •参考资料 [1]:https://www.cnblogs.com/wyxdrqc/p/10990378.html •题意 给出你一个包含 n 个点的树,这 n 个点编号为 1~n: 给出一个圆,圆上放置 n 个位置,第 i 个位置对应树中的某个节点,并且不重复: 求在圆上还原这棵树后,使得边不相交的总方案数: •题解 ①为何每一颗子树一定是连续的一段圆弧? 假设不是连续的圆弧,如图所示: 为了使 x 接到树上,必然会有 x-y 或 x-z 相连的边,这样…
Circle of Students time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn students standing in a circle in some order. The index of the ii-th student is pipi. It is guaranteed that a…
题目链接:https://codeforces.com/contest/1372/problem/D 题意 给出奇数个数围成的环,每次可以将一个数替换为相邻两个数的和并删除相邻的两个数,问最后余下的数的最大值. 题解 即从 $n$ 个数中选取 $\frac{n+1}{2}$ 个数,且这些数中最多有一对数相邻的和的最大值. 代码 #include <bits/stdc++.h> using ll = long long; using namespace std; int main() { int…
题意: 桌子上有 n 个石头围成一个环.每个石头都有一种颜色.每种颜色可以由小写英文字母表示.如果每一对相邻的石头都是不同颜色的,则称这 n 个石头构成的环是美丽的.现在,你可以从这 n 个石头中拿走一段连续的石头(可以为空),且你只能拿一次. 对于每个 k(0≤k≤n−1) ,判断是否存在一种取石头的方案,使得在拿走 k 个连续的石头后,剩下的 n−k 个石头构成的环是美丽的. n<=1000000 正解kmp,转换思路,不去考虑拿走什么,考虑留下什么,不去考虑什么合法,去考虑哪些是违法的.…
https://codeforc.es/contest/1189/problem/B 优先考虑最大的元素怎么构造.拿两个次大的围着他就很好,但是其他的怎么安排呢?就直接降序排列就可以了. a数组还开错了. #include<bits/stdc++.h> using namespace std; typedef long long ll; int n; int a[100005]; int main() { #ifdef Yinku freopen("Yinku.in", &…
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定两个点集 M 与 S,求是否存在一个圆能够分割两个点集. 原题传送门. @solution@ 不妨考虑圆内是 M,圆外是 S 的情况.反过来同理. 如果 M 只有一个点,显然有解:否则至少可以让分割圆经过 M 的凸包上的某两个点. 一个暴力做法是枚举这两个点 x, y,则其他点会对分割圆的位置产生限制.可以用 \(\vec{xy}\) 所对圆周角大小来描述这…
这题也太新颖了吧.. 交互博弈 以前一直以为交互只能出二分 题意:长度为n的环形灯 玩家有两种操作 结束游戏 或者选择k个灯点亮 每次这个k是玩家自己选的 玩家操作后让电脑操作 电脑选择一个最优的点x 然后关掉从x开始的连续k个灯 玩家想要点亮更多的灯 电脑则相反 让你来操作 如果达到了理论上最多灯的状态就算ac了 题解:模拟一下操作就找到规律了.. 如果玩家上一次操作点亮了k个灯 如果当前连续亮灯的最长序列为x <= k 那么电脑操作了之后 至少会多点亮一个灯 就这样一直贪心下去.. 所以我们…
CodeForces 140A New Year Table Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u  Description Gerald is setting the New Year table. The table has the form of a circle; its radius equals R. Gerald invited many guests and is…
Megacity Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Inste…
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hierog…
A. Peter and Snow Blower 题目连接: http://www.codeforces.com/contest/613/problem/A Description Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not…
B. Fox And Two Dots 题目连接: http://codeforces.com/contest/510/problem/B Description Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n × m cells, like this: Each cell contains a dot that ha…
Evil Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463/attachments Description Richard is evil. He wants to give another geometry problem to the participants of this contest and I’m afraid I have no choice but to comply. W…
E. Bindian Signalizing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/5/E Description Everyone knows that long ago on the territory of present-day Berland there lived Bindian tribes. Their capital was surrounded…
A. Flea travel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem/A Description A flea is sitting at one of the n hassocks, arranged in a circle, at the moment. After minute number k the flea jumps through k - 1hass…
D. Max and Bike Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/problem/D Description For months Maxim has been coming to work on his favorite bicycle. And quite recently he decided that he is ready to take part in a cy…
B. Kolya and Tanya Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/problem/B Description Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the v…
CodeForces Round 199 Div2   完了,这次做扯了,做的时候有点发烧,居然只做出来一道题,差点被绿. My submissions     # When Who Problem Lang Verdict Time Memory 4434550 Sep 9, 2013 11:57:20 AM OIer E - Xenia and Tree GNU C++ Accepted 842 ms 4260 KB 4434547 Sep 9, 2013 11:56:11 AM OIer…
题目链接 :http://codeforces.com/contest/158/problem/D D. Ice Sculptures time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The Berland University is preparing to celebrate the 256-th anniversary…
http://codeforces.com/problemset/problem/786/A Description Rick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer. In this game…
题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include <bits/stdc++.h> using namespace std; int a[210]; int n; int main() { scanf("%d", &n); for(int i=1; i<=2*n; i++) scanf("%d", &…
B. Gleb And Pizza time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Gleb ordered pizza home. When the courier delivered the pizza, he was very upset, because several pieces of sausage lay on…