题目传送门 /* 线段树的单点更新:有一个交叉更新,若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 <…
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…
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…
题目链接 传送门 思路 \(dp[i][j][k]\)表示第\(i\)次操作放\(j\)后与另一堆的重量差为\(k\)是否存在. 代码实现如下 #include <set> #include <map> #include <deque> #include <queue> #include <stack> #include <cmath> #include <ctime> #include <bitset> #i…
看了codeforces上的大神写的题解之后,才知道这道题水的根本! 不过相对前面两题来说,这道题的思维要难一点: 不过想到了水的根本,这题也真心不难: 方法嘛,就像剥洋葱一样,从外面往里面剥: 所以呢,dfs,每次往左或者往右找到乱序的那个元素,反转一下: 这样就行了,而且题目说了保证能够在三次内搞定: 证明我也不会,意思应该就是这样了! #include<cstdio> #include<vector> #include<algorithm> #define max…
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…
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…
题目链接: 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]…