#include <iostream>
#include <bitset>
#include <list>
#include <vector>
#include <cassert>
constexpr int max_n=35;
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
int n, m;
std::cin>>n>>m;
int t[m][2];
for (size_t i=0; i<m; ++i){
std::cin>>t[i][0]>>t[i][1];
--t[i][0], --t[i][1];
}
//size_t MAR=0;
for (int i=1; i<=n; ++i){
int res=0;
for (int start=0; start+i<=n; ++start){
std::bitset<max_n> tmp;
for (size_t j=start; j<=start+i-1; ++j){
tmp[j]=true;
}
std::list<std::bitset<max_n> >dp;
dp.push_back(tmp);
bool ok=true;
for (int x=m-1; x>=0; --x){
int a=t[x][0], b=t[x][1];
std::bitset<max_n> X;
X[a]=true;
X[b]=true;
int s=dp.size();
auto it=dp.begin();
for (int i=0; i<s; ++i){
if ((*it)[a] and !(*it)[b]){
it=dp.erase(it);
}else{
if (!(*it)[a] and (*it)[b]){
dp.push_back(*it^X);
}
++it;
}
}
if (dp.empty())break;
//MAR=std::max(MAR,dp.size());
//std::cout<<dp.size()<<'\n';
}
res+=dp.size()%2;
}
std::cout<<res%2<<' ';
}
std::cout<<'\n';
//std::cout<<MAR<<'\n';
}
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 | #include <iostream> #include <bitset> #include <list> #include <vector> #include <cassert> constexpr int max_n=35; int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(0); int n, m; std::cin>>n>>m; int t[m][2]; for (size_t i=0; i<m; ++i){ std::cin>>t[i][0]>>t[i][1]; --t[i][0], --t[i][1]; } //size_t MAR=0; for (int i=1; i<=n; ++i){ int res=0; for (int start=0; start+i<=n; ++start){ std::bitset<max_n> tmp; for (size_t j=start; j<=start+i-1; ++j){ tmp[j]=true; } std::list<std::bitset<max_n> >dp; dp.push_back(tmp); bool ok=true; for (int x=m-1; x>=0; --x){ int a=t[x][0], b=t[x][1]; std::bitset<max_n> X; X[a]=true; X[b]=true; int s=dp.size(); auto it=dp.begin(); for (int i=0; i<s; ++i){ if ((*it)[a] and !(*it)[b]){ it=dp.erase(it); }else{ if (!(*it)[a] and (*it)[b]){ dp.push_back(*it^X); } ++it; } } if (dp.empty())break; //MAR=std::max(MAR,dp.size()); //std::cout<<dp.size()<<'\n'; } res+=dp.size()%2; } std::cout<<res%2<<' '; } std::cout<<'\n'; //std::cout<<MAR<<'\n'; } |
English