#pragma GCC optimize("O3") #include <bits/stdc++.h> #define fi first #define se second #define pn printf("\n") #define ssize(x) int(x.size()) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define bitcount(x) __builtin_popcount(x) #define bitcountll(x) __builtin_popcountll(x) #define clz(x) __builtin_clz(x) #define ctz(x) __builtin_ctz(x) using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<int, ll> pil; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef double db; typedef long double ldb; #define vv vector int inf = 2e09; ll infll = 2e18; int mod = (1<<23)*119+1; void answer(){ int n, m; scanf("%d%d", &n, &m); vv<pii> e(m); for(int i = 0; i < m; ++i) scanf("%d%d", &e[i].fi, &e[i].se), --e[i].fi, --e[i].se; reverse(all(e)); vv<ll> t[2]; for(int i = 0; i < n; ++i){ ll nr = 0; for(int j = i; j < n; ++j) nr += 1ll<<j, t[0].emplace_back(nr); } int jj, ii; for(int i = 0; i < m; ++i){ ll a = 1ll<<e[i].fi, b = 1ll<<e[i].se; ii = i&1, jj = (i^1)&1; t[jj] = vv<ll>(); for(ll u : t[ii]){ if((u&a) && (~u&b)) continue; if((u&b) && (~u&a)) t[jj].emplace_back(u^b^a); t[jj].emplace_back(u); } } vv<ll> res(n+1); for(ll u : t[m&1]) ++res[bitcountll(u)]; for(int i = 1; i <= n; ++i) printf("%lld ", res[i]&1); pn; } signed main(){ int T = 1; //~ scanf("%d", &T); //~ ios_base::sync_with_stdio(0); cin.tie(0); //cin >> T; for(++T; --T; ) answer(); 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 | #pragma GCC optimize("O3") #include <bits/stdc++.h> #define fi first #define se second #define pn printf("\n") #define ssize(x) int(x.size()) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define bitcount(x) __builtin_popcount(x) #define bitcountll(x) __builtin_popcountll(x) #define clz(x) __builtin_clz(x) #define ctz(x) __builtin_ctz(x) using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<int, ll> pil; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef double db; typedef long double ldb; #define vv vector int inf = 2e09; ll infll = 2e18; int mod = (1<<23)*119+1; void answer(){ int n, m; scanf("%d%d", &n, &m); vv<pii> e(m); for(int i = 0; i < m; ++i) scanf("%d%d", &e[i].fi, &e[i].se), --e[i].fi, --e[i].se; reverse(all(e)); vv<ll> t[2]; for(int i = 0; i < n; ++i){ ll nr = 0; for(int j = i; j < n; ++j) nr += 1ll<<j, t[0].emplace_back(nr); } int jj, ii; for(int i = 0; i < m; ++i){ ll a = 1ll<<e[i].fi, b = 1ll<<e[i].se; ii = i&1, jj = (i^1)&1; t[jj] = vv<ll>(); for(ll u : t[ii]){ if((u&a) && (~u&b)) continue; if((u&b) && (~u&a)) t[jj].emplace_back(u^b^a); t[jj].emplace_back(u); } } vv<ll> res(n+1); for(ll u : t[m&1]) ++res[bitcountll(u)]; for(int i = 1; i <= n; ++i) printf("%lld ", res[i]&1); pn; } signed main(){ int T = 1; //~ scanf("%d", &T); //~ ios_base::sync_with_stdio(0); cin.tie(0); //cin >> T; for(++T; --T; ) answer(); return 0; } |