C - Xenia and Ringroad】的更多相关文章

Problem description Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise. Xenia has recently moved into the r…
time limit per test : 2 seconds memory limit per test : 256 megabytes input : standard input output : standard output Xenia lives in a city that has nnn houses built along the main ringroad. The ringroad houses are numbered 111 through nnn in the clo…
题目链接:http://codeforces.com/problemset/problem/339/B 题目理解不难,这句是解题的关键 In order to complete the i-th task, she needs to be in the house number ai and complete all tasks with numbers less than i .从样例1的提示,可以知道,如果a[i] > a[i+1],则需要继续顺时针走下去,直到到达n,接着重新从1开始数,直…
题意:给定 n 个地方,然后再给 m 个任务,每个任务必须在规定的地方完成,并且必须按顺序完成,问你最少时间. 析:没什么可说的,就是模拟,记录当前的位置,然后去找和下一个位置相差多长时间,然后更新当前位置即可. 代码如下: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; typedef long long LL; int main(){ int n, m, x; while(cin >>…
A.题意就是把字符串里面的数字按增序排列,直接上代码. #include <string.h> #include <stdio.h> #include <algorithm> using namespace std; int main() { char s[1005]; int num[105]; while (scanf("%s" , s) != EOF) { int l = strlen(s); int t = 0; int cnt = 0; f…
A. Helpful Maths 题目大意 给一个连加计算式,只包含数字 1.2.3,要求重新排序,使得连加的数字从小到大 做法分析 把所有的数字记录下来,从小到大排序输出即可 参考代码 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; ; ]; ], n; int main() { scanf("%s…
这次出的题水爆了,借着这个机会终于把CF的号变蓝了.A. Helpful Mathstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputXenia the beginner mathematician is a third year student at elementary school. She is now learning the add…
A.Helpful Maths 分析:将读入的字符转化为数字,直接排个序就可以了. #include <cstdlib> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; ; int seq[N]; int main() { char c; , idx = ; while ((c = getchar()) != EOF) { if (c == '+'…
Description Xenia the programmer has a tree consisting of n nodes. We will consider the tree nodes indexed from 1 to n. We will also consider the first node to be initially painted red, and the other nodes — to be painted blue. The distance between t…
[codeforces 339]D. Xenia and Bit Operations 试题描述 Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided t…
[codeforces 339]C. Xenia and Weights 试题描述 Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by on…
Xenia and Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Xenia the mathematician has a sequence consisting of n (n is divisible by 3) positive integers, each of them is at most 7…
Xenia and Bit Operations time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is…
Xenia and Weights time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play wi…
题目传送门 /* 线段树的单点更新:有一个交叉更新,若rank=1,or:rank=0,xor 详细解释:http://www.xuebuyuan.com/1154895.html */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <cmath> #include <…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Xenia and Bit Operations Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better unders…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Xenia and Weights Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud D. Xenia and Dominoes Xenia likes puzzles very much. She is especially fond of the puzzles that consist of domino pieces. Look at the picture that shows one of such puzzles. A puzzle is a 3 ×…
B. Xenia and Spies time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Xenia the vigorous detective faced n (n ≥ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to…
D. Xenia and Bit Operations time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia…
题目链接: B. Xenia and Hamming 题意: 要求找到复制后的两个字符串中不同样的字符 思路: 子问题: 在两串长度是最大公倍数的情况下, 求出一个串在还有一个串中反复字符的个数 CODE: #include <iostream> #include<stdio.h> #include<string> #include<string.h> using namespace std; #define M 1000006 int com[M][26]…
Xenia and Bit Operations Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 339D Description Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, …
Xenia and Bit Operations CodeForces - 339D Xenia the beginner programmer has a sequence a, consisting of 2nnon-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calcu…
先上题目: D. Xenia and Hamming time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Xenia is an amateur programmer. Today on the IT lesson she learned about the Hamming distance. The Hamming distanc…
Xenia and Bit Operations time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is…
Xenia and Colorful Gems 题意 给出三个数组,在每个数组中选择一个数字x,y,z,,使得\((x-y)^2+(y-z)^2+(x-z)^2\)最小. 思路 我们假设x<=y<=z 枚举所有的数作为y时,可以取得的最小值. 具体实现:使用vectorvec[4]存三个数组里的数字. 定义一个数组arr[]={1,2,3},对它进行全排列,每次枚举vec[arr[2]]里的元素作为y,vec[arr[1]]里的元素作为x,vec[arr[3]]里的元素作为z. x取第一个&l…
LINK:Xenia and Colorful Gems 考试的时候没想到一个很好的做法. 赛后也有一个想法. 可以考虑答案的样子 x,y,z 可以发现 一共有 x<=y<=z,z<=y<=z,y<=x<=z... 6种情况 考虑 y<=x<=z 观察这个形式 枚举x 发现y在<=x中显然取较大的那个更优 证明的话 x不变 在z不变的情况 y在符合条件的情况下自然 越小越不优 再讨论z越大的问题 再讨论y z一个变小一个变大的情况 综上可以发现 y z…
Codeforce 342 E. Xenia and Tree 解析(思維.重心剖分) 今天我們來看看CF342E 題目連結 題目 給你一棵樹,有兩種操作,把某點標成紅色或者查詢離某點最近的紅點有多遠. 前言 這題我是當作學習重心剖分的習題看待的,最詳細的版本請看教學文 @copyright petjelinux 版權所有 觀看更多正版原始文章請至petjelinux的blog 想法 每兩個樹上的點,其重心剖分樹(CD樹)上的\(LCA\)一定在其最短路徑上.因此當我們把點\(v\)塗成紅色時,…
题目链接 2了,差点就A了...这题真心不难,开始想的就是暴力spfa就可以,直接来了一次询问,就来一次的那种,TLE了,想了想,存到栈里会更快,交又TLE了..无奈C又被cha了,我忙着看C去了...这题,是我一个地方写错了..top = 0的时候会死循环吗?貌似不会把,反正我加了这个判断,就A了,可能优化了一下把. #include <cstring> #include <cstdio> #include <string> #include <iostream…
题目链接:http://codeforces.com/problemset/problem/342/B 题目意思:有n个spy,编号从1-n,从左到右排列.现在的任务是,spy s要把信息传递到spy f,但必须要满足:当spy li - spy ri 被观看时,这一段spy不能传递信息. 要注意的是,step数(也就是ti)不一定是按顺序排列下来的,它有可能与上一行的step相差好几轮.此时,这好几轮中,spy s 是可以继续往spy f的方向传递信息的,直到移动完这好几轮的数目为止.除此,有…