———————————————————————————— 这道题维护一下原序列的差分以及操作的差分就可以了 记得倒着差分操作 因为题目保证操作2的l r 小与当前位置 #include<cstdio> #include<cstring> #include<algorithm> #define lowbit(x) x&-x; using namespace std; ,mod=1e9+; int read(){ ,f=,c=getchar(); ; c=getch…
这道题我们发现0就代表相同1代表少1或者大1 那么我们根据题目连边 如果存在1(边权只为或0)个数为奇数的环就是无解 #include<cstdio> #include<cstring> #include<algorithm> ; int read(){ ,f=,c=getchar(); ; c=getchar();} +(c-'); c=getchar();} return ans*f; } int T,n,q,vis[M],c[M]; int first[M],cn…
Codechef September Challenge 2018 游记 Magician versus Chef 题目大意: 有一排\(n(n\le10^5)\)个格子,一开始硬币在第\(x\)个格子里.\(m(m\le10^4)\)次操作,每次交换指定的两个格子.问最后硬币在第几个格子里. 思路: 按题意模拟即可. 源代码: #include<cstdio> #include<cctype> inline int getint() { register char ch; whi…
Little Chef and Sums 分析:水题,去维护一下前缀和以及后缀和就好,注意long long #include "iostream" #include "cstdio" #include "cstring" #include "string" using namespace std; ; ; long long a[maxn],dp[maxn]; int n; int main() { int T; scanf…
https://www.codechef.com/JAN17 Cats and Dogs 签到题 #include<cstdio> int min(int a,int b){return a<b?a:b;} int main(){ int T,a,b,c; for(scanf("%d",&T);T;--T){ scanf("%d%d%d",&a,&b,&c); puts(c%==&&c/<=a+…
题目链接:http://www.codechef.com/JAN14/problems/SEAGRP [题意] 给n个点,m条边的无向图,判断是否有一种删边方案使得每个点的度恰好为1. [分析] 从结论入手,每个点的度恰好为1,那么就意味着每个点只能连接一个点,这样问题就转化为图中的点能否刚好两两配对. 对于奇数个点肯定是不行的,因为一定存在一个点不存在与之配对的点.    如果点是偶数,那么就要求这个图的最大匹配,看匹配树是否为点数的一半. 求匹配的方法和二分图类似,不断找增广路更新匹配数就好…
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/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/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 {…