https://www.codechef.com/DEC17/problems/VK18 #include<cstdio> #include<iostream> #include<algorithm> using namespace std; #define N 1000001 ],dp[N]; ]; void read(int &x) { x=; char c=getchar(); while(!isdigit(c)) c=getchar(); +c-'; c…
https://www.codechef.com/DEC17/problems/CHEFEXQ 题意: 位置i的数改为k 询问区间[1,i]内有多少个前缀的异或和为k 分块 sum[i][j] 表示第i块内,有多少个前缀,他们的异或和为j a[i] 表示 位置i的数 位置i改为k: 若 g=x1^x2^x3…… 把 x1 改为 k 后,那新的g=x1^x1^k^x2^x3…… 所以修改可以看做整体异或 修改后的值^原来的值 即 区间[i,n] 异或上a[i]^k i所在块单个改,后面的块整体打标…
https://www.codechef.com/DEC17/problems/CHEFHAM #include<cstdio> #include<cstring> #include<iostream> using namespace std; #define N 100001 int a[N],b[N]; ]; int num1[N],num2[N]; void read(int &x) { x=; char c=getchar(); while(!isdig…
https://www.codechef.com/DEC17/problems/CPLAY #include<cstdio> #include<algorithm> using namespace std; ]; int main() { int sumA,sumB; )!=EOF) { sumA=sumB=; int i; ;i<=;++i) { ) { ') { sumA++; -i+)/) break; } else { -i)/) break; } } else {…
https://www.codechef.com/DEC17/problems/GIT01 #include<cstdio> #include<algorithm> using namespace std; #define N 101 char s[N]; int main() { int T; scanf("%d",&T); int n,m; int OddG,OddR,EvenG,EvenR; int ans; while(T--) { OddG=O…
http://codeforces.com/contest/484/problem/A 题意: 询问[a,b]中二进制位1最多且最小的数 贪心,假设开始每一位都是1 从高位i开始枚举, 如果当前数>b,且减去1<<i后仍>=a,就减1<<i 当当前数在[a,b]之间时,输出 因为从高位开始减,所以保证当前数是最小的 #include<cstdio> #include<iostream> using namespace std; typedef l…
http://codeforces.com/contest/484/problem/E 题意: 给出n个数,查询最大的在区间[l,r]内,长为w的子区间的最小值 第i棵线段树表示>=i的数 维护最长连续子区间 把数从大到小插入主席树 对于每个询问,二分x 在第x棵线段树中查,若最长连续子区间>=w,到代表更大的线段树中查 没有建第n+1棵线段树,导致前面节点的siz不对,WA了一次 #include<cstdio> #include<iostream> #include…
http://codeforces.com/problemset/problem/896/C 题意: 对于一个随机序列,执行以下操作: 区间赋值 区间加 区间求第k小 区间求k次幂的和 对于随机序列,可以使用Old Driver Tree 就是将序列中,连续的相同值域合并为一段 然后暴力操作 #include<set> #include<vector> #include<cstdio> #include<iostream> #include<algor…
http://codeforces.com/problemset/problem/351/D 题意: n个数的一个序列,m个操作 给出操作区间[l,r], 首先可以删除下标为等差数列且数值相等的一些数 然后可以对区间剩余数重排 继续删除下标为等差数列且数值相等的一些数 继续对区间进行重排 直至区间内没有数 问每次操作的最少删除次数 因为每次删除后可以重排 那么完全可以在第一次删除后就把区间相等的数排在一起 这样相等的数的下标就分别构成了公差为1的等差数列 所以问题转化为 设区间[l,r]内数有x…
http://codeforces.com/contest/896/problem/A 第i个字符串嵌套第i-1个字符串 求第n个字符串的第k个字母 dfs #include<map> #include<cstdio> #include<iostream> using namespace std; typedef long long LL; ]={" What are you doing at the end of the world? Are you bus…