脑子抽,黄题都不会做惹……调了半天硬是越调分越低/kk
#include <bits/stdc++.h>
const int MX = 65537;
using namespace std;
long long n, b;
map<int, int> mp;
int nl[20], ll[20], a[65540][20];
int main()
{
scanf("%lld%lld", &n, &b);
for(int i = 1; i <= n; i++)
{
int x;
scanf("%d", &x), ll[i] = x;
}
for(int i = 1; i <= MX; i++)
{
int llb = 1;
for(int j = 1; j <= n; j++) llb = llb*10+ll[j];
if(mp[llb])
{
int d = mp[llb];
for(int j = 1; j <= n; j++) printf("%d\n", a[b%(i-d+1)+d][j]);
break;
}
for(int j = 1; j <= n; j++) a[i][j] = ll[j];
mp[llb] = i;
if(ll[n]) nl[1] = !ll[1];
else nl[1] = ll[1];
//for(int j = 1; j <= n; j++) cout << ll[j];
//cout << endl;
for(int j = 2; j <= n; j++)
if(ll[j-1]) nl[j] = !ll[j];
else nl[j] = ll[j];
if(i == b)
{
for(int j = 1; j <= n; j++) printf("%d\n", nl[j]);
break;
}
for(int j = 1; j <= n; j++) ll[j] = nl[j], nl[j] = 0;
}
return 0;
}