您的位置:首页 > 其它

[构造] Codeforces Gym 101173 CERC 16 K & BZOJ 4796 Key Knocking

2017-03-30 21:11 453 查看
每三个一起考虑

不论如何 我们都可以进行最多一次操作使得答案加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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: