题目传送门 /* 线段树的单点更新:有一个交叉更新,若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 <…
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to becom…
看了codeforces上的大神写的题解之后,才知道这道题水的根本! 不过相对前面两题来说,这道题的思维要难一点: 不过想到了水的根本,这题也真心不难: 方法嘛,就像剥洋葱一样,从外面往里面剥: 所以呢,dfs,每次往左或者往右找到乱序的那个元素,反转一下: 这样就行了,而且题目说了保证能够在三次内搞定: 证明我也不会,意思应该就是这样了! #include<cstdio> #include<vector> #include<algorithm> #define max…
http://codeforces.com/contest/339/ 这场正是水题大放送,在家晚上限制,赛后做了虚拟比赛 A,B 乱搞水题 C 我是贪心过的,枚举一下第一个拿的,然后选使差值最小的那个物品. code D 裸的线段树,几乎不用思考,push_up函数要注意一下即可 code E 最多三层,暴力搜一下.按以下两个方向搜索 1.找到左边第一个不匹配点l,从右往左找到标号为l的位置r,翻转区间<l, r> 2.找到右边第一个不匹配点r,从右往左找到标号为l的位置l,翻转区间<l…
A. Helpful Maths 题目大意 给一个连加计算式,只包含数字 1.2.3,要求重新排序,使得连加的数字从小到大 做法分析 把所有的数字记录下来,从小到大排序输出即可 参考代码 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; ; ]; ], n; int main() { scanf("%s…
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 == '+'…
开了个小号做,C题一开始看错范围,D题看了半小时才看懂,居然也升到了div1,囧. C - Xenia and Weights 给出一串字符串,第i位如果是1的话,表示有重量为i的砝码,如果有该种砝码的话,数量有无限多个. 现在往天平的两侧放入,每次放入的要求: 1.每次放入时和上次放入的砝码的重量不能一样. 2.放入的那端天平必须必另一端重. 问能否放入n次,能的话,求放入方式. 分析: 比赛时看到很多人写的是贪心,但是想不到有什么好的数据叉掉他们,囧. 我写的是直接dfs爆搜.代码略吧. D…
哎....这次的比赛被安叔骂的好惨! 不行呢,要虐回来: 这道搜索,老是写错,蛋疼啊! 果然是基础没打好! #include<cstdio> using namespace std; ],m; ],flag=true; void dfs(int n,int ch,int x) { if(n>m) { flag=false; printf("YES\n"); ; i<n; ++i) printf(" %d",ans[i]); printf(&q…
这题也是一个线段树的水题: 不过开始题目没看明白,害得我敲了一个好复杂的程序.蛋疼啊.... 最后十几分钟的时候突然领悟到了题意,但是还是漏掉一个细节,老是过不去... 以后比赛的时候不喝啤酒了,再也不喝了.... 贴上代码: #include<cstdio> #include<cstring> #define maxn 262200 using namespace std; struct tree { int num; int l,r; tree *left,*right; }…
也是水题一个,不过稍微要细心点.... 贴代码: #include<iostream> using namespace std; long long n,m; ; int main() { ,t; cin>>n>>m; cin>>s; ans=s-; ;i<m;i++) { cin>>t; if(t<s) ans+=(n-s+t); else ans+=(t-s); s=t; } cout<<ans<<endl…
水题一个: 直接贴代码: #include<cstdio> #include<algorithm> #include<cstring> using namespace std; ]; ]; int main() { ; scanf("%s",s); ;i<strlen(s);i++) { if(s[i]!='+') num[cnt++]=s[i]-'; } ) {printf(;} sort(num,num+cnt); ;i<cnt-;i…
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…
题目链接 传送门 思路 \(dp[i][j][k]\)表示第\(i\)次操作放\(j\)后与另一堆的重量差为\(k\)是否存在. 代码实现如下 #include <set> #include <map> #include <deque> #include <queue> #include <stack> #include <cmath> #include <ctime> #include <bitset> #i…
A. Helpful Maths time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.…
C. Efim and Strange Grade 题目连接: http://codeforces.com/contest/719/problem/C Description Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappoin…
B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/556/problem/B Description Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famou…
B. Ohana Cleans Up Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/problem/B Description Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clea…
A. Kyoya and Photobooks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/problem/A Description Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", a…
A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/A Description One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said…
A. Wilbur and Swimming Pool Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/problem/A Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his back…
D. Mr. Kitayuta's Colorful Graph Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/506/problem/D Description Mr. Kitayuta has just bought an undirected graph with n vertices and m edges. The vertices of the graph are numbered…
A. The Child and Toy Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/problem/A Description On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy…
C. Duff and Weight Lifting Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/problem/C Description Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of wei…
B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/560/problem/B Description Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a…
A. Currency System in Geraldion Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/560/problem/A Description A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But t…
A. Kefa and First Steps Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/580/problem/A Description Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≤ i ≤ n) h…
题目链接:http://codeforces.com/problemset/problem/450/A ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943…
A. Fake NP time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.…
https://codeforces.com/contest/1061/problem/F 题意 假设存在一颗完全k叉树(n<=1e5),允许你进行最多(n*60)次询问,然后输出这棵树的根,每次询问,a,b,c三个点,会返回b是否在a,c之间的路径上 思路 粗略看了下询问次数,可以知道,你最多可以询问60对不同的点,每对点遍历n个点,可以知道n个点在不在这两个点的中间 一开始的思路是,随机找两个点,遍历所有点,然后记录在他们中间的点,在里面再找两个点,继续上述操作,知道剩下一个点,但是假设某一…
A. Vitya in the Countryside 题目连接: http://codeforces.com/contest/719/problem/A Description Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the…