点此进入比赛 这次比赛本来想好好打的,但不幸的是,这周先是要认真复习准备月考,考完又是发烧在床上躺了一个周末,所以最终没能打完. 我还是好弱啊. \(T1\):Binary XOR(点此看题面) 大致题意: 给定两个长度为\(n\)的\(01\)串,你能任意打乱两个字符串中的字符顺序,求所能得到的异或值个数. 设第一个字符串中有\(t1\)个\(1\),第二个字符串中有\(t2\)个\(1\). 我们枚举有恰好\(i\)位满足两个字符串该位都是\(1\),则异或所得串中就有\(t1+t2-2\t…
点此进入比赛 \(T1\):Football(点此看题面) 大致题意: 求\(max(20a_i-10b_i,0)\). 送分题不解释. #include<bits/stdc++.h> #define Tp template<typename Ty> #define Ts template<typename Ty,typename... Ar> #define Reg register #define RI Reg int #define Con const #defi…
Codechef April Challenge 2019 游记 Subtree Removal 题目大意: 一棵\(n(n\le10^5)\)个结点的有根树,每个结点有一个权值\(w_i(|w_i\le10^9|)\).你可以进行若干次(包括\(0\)次)操作,每次你可以选择一个连通块,将其删去.若你的操作次数为\(k\),则总收益为剩下结点权值之和\(-X\cdot k\).求最大总收益. 思路: 树形DP,\(f_x\)表示以\(x\)为根的子树的最大总收益.转移时\(f_x=w_x+\s…
Preface 老年菜鸡终于开始打CC了,由于他太弱了所以只能打Div2 因为台风的原因challenge并没有写,所以水了个Rank7 A Football SB模拟题不解释 #include<cstdio> #include<iostream> #define RI register int using namespace std; const int N=155; int t,n,a[N],b[N],ans; int main() { for (scanf("%d&…
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 {…
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…
传送门 \(Maximum\ Remaining\) 对于两个数\(a,b\),如果\(a=b\)没贡献,所以不妨假设\(a<b\),有\(a\%b=a\),而\(b\%a<a\).综上,我们可以发现答案就是严格次大值 //minamoto #include<bits/stdc++.h> #define R register #define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i) #define fd(i,a,b) for(R i…