#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
vector<pair<int,int>>t(m);
for(int i=0; i<m; i++)
cin>>t[i].first>>t[i].second;
for(int i=0; i<m; i++)
t[i].first--,t[i].second--;
auto bsc=[&](const bitset<35>& a, const bitset<35>& b)
{
return a.to_ulong()<b.to_ulong();
};
auto solve=[&](int w)
{
bitset<35>s;
for(int i=0; i<w; i++)
s[i]=1;
vector<bitset<35>>roz={s};
for(int i=0; i<n-w; i++)
s<<=1,roz.push_back(s);
//for(auto i:roz)
// cout<<i<<"\n";
//cout<<"dupa\n";
for(int i=m-1; i>=0; i--)
{
int a1=t[i].first,b1=t[i].second;
if(roz.size()==0)
break;
vector<bitset<35>>d1;
for(auto j:roz)
{
//cout<<j<<"nig\n";
if(j[a1]==0)
{
d1.push_back(j);
if(j[b1])
{
j[a1]=1;
j[b1]=0;
d1.push_back(j);
}
}
else
if(j[b1])
d1.push_back(j);
//cout<<j<<"\n";
}
roz.clear();
if(d1.size()==0)
break;
sort(d1.begin(),d1.end(),bsc);
int il=1;
for(int i=1; i<d1.size(); i++)
{
if(d1[i]!=d1[i-1])
{
if(il&1)
roz.push_back(d1[i-1]);
il=0;
}
il++;
}
if(il&1)
roz.push_back(d1[d1.size()-1]);
}
return roz.size()&1;
};
for(int i=0; i<n; i++)
cout<<solve(i+1)<<" ";
}
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 | #include <bits/stdc++.h> using namespace std; int main() { int n,m; cin>>n>>m; vector<pair<int,int>>t(m); for(int i=0; i<m; i++) cin>>t[i].first>>t[i].second; for(int i=0; i<m; i++) t[i].first--,t[i].second--; auto bsc=[&](const bitset<35>& a, const bitset<35>& b) { return a.to_ulong()<b.to_ulong(); }; auto solve=[&](int w) { bitset<35>s; for(int i=0; i<w; i++) s[i]=1; vector<bitset<35>>roz={s}; for(int i=0; i<n-w; i++) s<<=1,roz.push_back(s); //for(auto i:roz) // cout<<i<<"\n"; //cout<<"dupa\n"; for(int i=m-1; i>=0; i--) { int a1=t[i].first,b1=t[i].second; if(roz.size()==0) break; vector<bitset<35>>d1; for(auto j:roz) { //cout<<j<<"nig\n"; if(j[a1]==0) { d1.push_back(j); if(j[b1]) { j[a1]=1; j[b1]=0; d1.push_back(j); } } else if(j[b1]) d1.push_back(j); //cout<<j<<"\n"; } roz.clear(); if(d1.size()==0) break; sort(d1.begin(),d1.end(),bsc); int il=1; for(int i=1; i<d1.size(); i++) { if(d1[i]!=d1[i-1]) { if(il&1) roz.push_back(d1[i-1]); il=0; } il++; } if(il&1) roz.push_back(d1[d1.size()-1]); } return roz.size()&1; }; for(int i=0; i<n; i++) cout<<solve(i+1)<<" "; } |
English