[构造] Codeforces Gym 101173 CERC 16 K & BZOJ 4796 Key Knocking
2017-03-30 21:11
453 查看
每三个一起考虑
不论如何 我们都可以进行最多一次操作使得答案加2 就好了
不论如何 我们都可以进行最多一次操作使得答案加2 就好了
#include<cstdio> #include<cstdlib> #include<algorithm> #include<string> #include<cstring> using namespace std; const int N=1000005; char s ; int n; const int op[]={ 1,2,0,1,0,0,0,2,2,0,0,0,1,0,2,1 }; int ans ; int main(){ freopen("t.in","r",stdin); freopen("t.out","w",stdout); scanf("%s",s+1); n=strlen(s+1)/3; for (int i=1;i<=3*n;i++) s[i]-='0'; for (int i=0;i<n;i++){ int t=(s[3*i]<<3)+(s[3*i+1]<<2)+(s[3*i+2]<<1)+(s[3*i+3]<<0); if (op[t]){ ans[++*ans]=3*i+op[t]; s[3*i+op[t]]^=1,s[3*i+op[t]+1]^=1; } } printf("%d\n",*ans); for (int i=1;i<=*ans;i++) printf("%d ",ans[i]); return 0; }
相关文章推荐
- [构造] Codeforces Gym 101173 CERC 16 D & BZOJ 4790 Dancing Disks
- [状压DP Hall定理 折半] Codeforces Gym 101173 CERC 16 B & BZOJ 4788 Bipartite Blanket
- [分治 杂题] Codeforces Gym 101173 CERC 16 G & BZOJ 4792 Geohash Grid
- Codeforces Gym 101173 CERC 16 D & BZOJ 4790 Dancing Disks
- [2-SAT 构造] Codeforces Gym 101173 CERC 16 L. Lost Logic
- [高中数学联赛题] Codeforces Gym 101173 CERC 16 E. Easy Equation
- Codeforces Gym 101173 K. Key Knocking (构造)
- [构造] Codeforces Gym 101190 NEERC 16 C. Cactus Construction
- [树形DP 费用流手动增广] Codeforces Gym 101190 NEERC 16 M. Mole Tunnels
- [构造][度数序列的可图性]Codeforces Gym 100269K. Kids in a Friendly Class
- [杂题 交互] Codeforces Gym 101190 NEERC 16 I. Indiana Jones and the Uniform Cave
- [构造] Codeforces Gym 100553 NEERC 14 E. Epic Win!
- Codeforces Gym 101142 J. Java2016 (构造)
- Codeforces Gym 101173 J. Jazz Journey
- [可图性判定 Havel-Hakimi定理 构造] Codeforces Gym 100269 NEERC 13 Northern K. Kids in a Friendly Class
- [扫描线 杂题] Codeforces Gym 101190 NEERC 16 E. Expect to Wait
- Educational Codeforces Round 16 C. Magic Odd Square (构造)
- Codeforces Gym 100187K K. Perpetuum Mobile 构造
- [杂题] Codeforces Gym 101190 NEERC 16 L. List of Primes
- Codeforces Gym 100425H H - Football Bets 构造