A simple Blog for wyx I've been down the bottle hoping.
4796: [CERC2016]Key Knocking 构造
发表于: | 分类: Oi | 评论:0 | 阅读:242

搞笑题

看到这种直接告诉你几$n$啥的显然就是按几分块然后讨论

然后题目就是傻逼题,分16种情况枚举一下发现总存在一种方法使得操作小于等于一次然后3个数字的块贡献是2

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e6+5;
 
char str[N];
const int op[]={1,2,0,1,0,0,0,2,2,0,0,0,1,0,2,1};
int ans[N];
 
int main(){
    int n;
    scanf("%s", str+1);
    n = strlen(str+1) / 3;
    for(int i=1;i<=3*n;++i) str[i] -= '0';
    int top = 0;
    for(int i=0;i<n;++i) {
        int t = (str[3*i] << 3) + (str[3*i+1] << 2) + (str[3*i+2] << 1) + (str[3*i+3] << 0);
        if(op[t]) {
            ans [++top] = 3 * i + op[t];
            str[3*i+op[t]] ^= 1;
            str[3*i+op[t] + 1] ^= 1;
        }
    }
    cout << top << endl;
    for(int i=1;i<=top;++i) printf("%d ", ans[i]);
}
Title - Artist
0:00

站点地图 网站地图
Copyright © 2015-2017 A simple Blog for wyx
Powered by Typecho自豪的采用Sgreen主题

TOP