1 条题解
-
0
C++ :
#include<bits/stdc++.h> #define MAXN 200005 using namespace std; long long n,T; inline long long read(){ register char ch = getchar(); while(!isdigit(ch)) ch = getchar(); register long long rtn = 0; while(isdigit(ch)) rtn = rtn*10 + ch - '0' , ch = getchar(); return rtn; } int a[MAXN],f[MAXN]; inline void work(long long k , int h){ for(long long i = h;i<=n;++++i){ f[i] = 1 ^ a[((i-k)%n+n)%n] ^ a[(i+k)%n]; } f[0] = f[n] , f[n] = 0; for(int i = h^1;i<=n;++++i) f[i] = -1; memcpy(a,f,sizeof f); // for(int i=h;i<=n;++++i) printf("%d ",a[i]); puts(""); } int main(){ // freopen("1.in","r",stdin); n = read()<<1 , T = read(); for(int i=1;i<=n;++++i) a[i] = read()==1; for(long long i = 1,bg = 1;i <= T;i<<=1) if(T&i) work(i,bg = (bg+i)%2); for(int i=0;i<=n;++i) if(a[i]==-1) a[i] = 0; else if(a[i]==0) a[i] = 2; for(int i=1;i<n;++i) printf("%d ",a[i]); printf("%d",a[0]); return 0; }
- 1
信息
- ID
- 1002
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者