#include <bits/stdc++.h> #define ft first #define sc second #define pb push_back #define FOR(i,n) for(int i=0; i<n; i++) #define FORX(i,a,b) for(int i=(a); i<=(b); i++) #define watch(x) cerr << (#x) << " == " << (x) << endl typedef long long ll; typedef long double ld; using namespace std; vector<pair<uint_fast8_t,uint_fast8_t>> r; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; cin>>n>>m; FOR(i,m){ int a,b; cin>>a>>b; r.pb({a-1,b-1}); } reverse(r.begin(),r.end()); FORX(amt,1,n){ unordered_set<uint_fast64_t> curr, nxt; FOR(start,n-amt+1){ uint64_t row = 0; FOR(i,n){ if (start <= i && i < start+amt) { row |= (1LL<<i); } } curr.insert(row); } for (const auto &p : r) { for (const auto &row : curr) { uint64_t a = (1LL<<p.ft), b = (1LL<<p.sc); if (row&a && !(row&b)) {continue;} nxt.insert(row); if (!(row&a) && row&b) { uint64_t row_swap = row; row_swap ^= a; row_swap ^= b; nxt.insert(row_swap); } } swap(nxt, curr); nxt.clear(); } cout<<curr.size()%2<<" "; } cout<<"\n"; 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 | #include <bits/stdc++.h> #define ft first #define sc second #define pb push_back #define FOR(i,n) for(int i=0; i<n; i++) #define FORX(i,a,b) for(int i=(a); i<=(b); i++) #define watch(x) cerr << (#x) << " == " << (x) << endl typedef long long ll; typedef long double ld; using namespace std; vector<pair<uint_fast8_t,uint_fast8_t>> r; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; cin>>n>>m; FOR(i,m){ int a,b; cin>>a>>b; r.pb({a-1,b-1}); } reverse(r.begin(),r.end()); FORX(amt,1,n){ unordered_set<uint_fast64_t> curr, nxt; FOR(start,n-amt+1){ uint64_t row = 0; FOR(i,n){ if (start <= i && i < start+amt) { row |= (1LL<<i); } } curr.insert(row); } for (const auto &p : r) { for (const auto &row : curr) { uint64_t a = (1LL<<p.ft), b = (1LL<<p.sc); if (row&a && !(row&b)) {continue;} nxt.insert(row); if (!(row&a) && row&b) { uint64_t row_swap = row; row_swap ^= a; row_swap ^= b; nxt.insert(row_swap); } } swap(nxt, curr); nxt.clear(); } cout<<curr.size()%2<<" "; } cout<<"\n"; return 0; } |