//ANMHLIJKTJIY! #pragma GCC optimize(2) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector") #pragma GCC diagnostic error "-fwhole-program" #pragma GCC diagnostic error "-fcse-skip-blocks" #pragma GCC diagnostic error "-funsafe-loop-optimizations" #include <bits/stdc++.h> #define INF 1000000000 #define LINF 1000000000000000000 #define MOD 1000000007 #define mod 998244353 #define F first #define S second #define ll int #define N 1010 using namespace std; ll n,m,a[N],b[N],ans[N]; void upd(vector<ll> v) { ll i,j,mx=-1; for(i=0;i<n;i++) { if(v[i]==1) { mx=i; } } for(i=0;i<n;i++) { for(j=i;j<n;j++) { if(v[j]==0) { break; } if(mx!=-1&&j<mx) { continue; } ans[j-i+1]^=1; } if(v[i]==1) { break; } } return; } void dfs(vector<ll> cur,ll x) { while(x<m) { if(cur[a[x]]==-1&&cur[b[x]]==-1) { break; } if(cur[a[x]]==-1) { if(cur[b[x]]==0) { swap(cur[a[x]],cur[b[x]]); } } else if(cur[b[x]]==-1) { if(cur[a[x]]==1) { swap(cur[a[x]],cur[b[x]]); } } else if(cur[a[x]]==1&&cur[b[x]]==0) { swap(cur[a[x]],cur[b[x]]); } x++; } if(x==m) { upd(cur); return; } cur[a[x]]=cur[b[x]]=0; dfs(cur,x); cur[a[x]]=cur[b[x]]=1; dfs(cur,x); return; } int main(){ ll i; cin>>n>>m; for(i=0;i<m;i++) { cin>>a[i]>>b[i]; a[i]--,b[i]--; } vector<ll> qwq(n,-1); dfs(qwq,0); for(i=1;i<=n;i++) { cout<<ans[i]<<" "; } puts(""); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | //ANMHLIJKTJIY! #pragma GCC optimize(2) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector") #pragma GCC diagnostic error "-fwhole-program" #pragma GCC diagnostic error "-fcse-skip-blocks" #pragma GCC diagnostic error "-funsafe-loop-optimizations" #include <bits/stdc++.h> #define INF 1000000000 #define LINF 1000000000000000000 #define MOD 1000000007 #define mod 998244353 #define F first #define S second #define ll int #define N 1010 using namespace std; ll n,m,a[N],b[N],ans[N]; void upd(vector<ll> v) { ll i,j,mx=-1; for(i=0;i<n;i++) { if(v[i]==1) { mx=i; } } for(i=0;i<n;i++) { for(j=i;j<n;j++) { if(v[j]==0) { break; } if(mx!=-1&&j<mx) { continue; } ans[j-i+1]^=1; } if(v[i]==1) { break; } } return; } void dfs(vector<ll> cur,ll x) { while(x<m) { if(cur[a[x]]==-1&&cur[b[x]]==-1) { break; } if(cur[a[x]]==-1) { if(cur[b[x]]==0) { swap(cur[a[x]],cur[b[x]]); } } else if(cur[b[x]]==-1) { if(cur[a[x]]==1) { swap(cur[a[x]],cur[b[x]]); } } else if(cur[a[x]]==1&&cur[b[x]]==0) { swap(cur[a[x]],cur[b[x]]); } x++; } if(x==m) { upd(cur); return; } cur[a[x]]=cur[b[x]]=0; dfs(cur,x); cur[a[x]]=cur[b[x]]=1; dfs(cur,x); return; } int main(){ ll i; cin>>n>>m; for(i=0;i<m;i++) { cin>>a[i]>>b[i]; a[i]--,b[i]--; } vector<ll> qwq(n,-1); dfs(qwq,0); for(i=1;i<=n;i++) { cout<<ans[i]<<" "; } puts(""); return 0; } |