#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair <int, int>; using pll = pair <ll, ll>; const int inf = 1e9+7; const ll inf_ll = 1e18+7; void boost() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n, m, a[1007], b[1007], res[40]; vector<ll> v, pom; int main() { boost(); cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> a[i] >> b[i]; } for (int i = 1; i <= n; i++) { ll maska = 0; for (int j = i; j <= n; j++) { maska |= ((ll)1 << j); v.push_back(maska); } } for (int rozkaz = m; rozkaz > 0; rozkaz--) { pom.clear(); //cout << "rozkaz: " << rozkaz << "\n"; for (ll maska: v) { //cout << "maska: " << maska << "\n"; if ((maska & ((ll)1 << a[rozkaz])) != 0 && (maska & ((ll)1 << b[rozkaz])) == 0) continue; pom.push_back(maska); if ((maska & ((ll)1 << a[rozkaz])) == 0 && (maska & ((ll)1 << b[rozkaz])) != 0) { ll nowa_maska = maska; nowa_maska ^= ((ll)1 << a[rozkaz]); nowa_maska ^= ((ll)1 << b[rozkaz]); pom.push_back(nowa_maska); } } v.clear(); for (ll maska: pom) v.push_back(maska); } for (ll maska: v) { int ile = 0; for (int i = 1; i <= n; i++) { if ((maska & ((ll)1 << i)) != 0) ile++; } res[ile]++; } for (int i = 1; i <= n; i++) { //cout << res[i] << " "; cout << res[i] % 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 62 63 64 65 66 67 68 69 70 71 | #include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair <int, int>; using pll = pair <ll, ll>; const int inf = 1e9+7; const ll inf_ll = 1e18+7; void boost() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n, m, a[1007], b[1007], res[40]; vector<ll> v, pom; int main() { boost(); cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> a[i] >> b[i]; } for (int i = 1; i <= n; i++) { ll maska = 0; for (int j = i; j <= n; j++) { maska |= ((ll)1 << j); v.push_back(maska); } } for (int rozkaz = m; rozkaz > 0; rozkaz--) { pom.clear(); //cout << "rozkaz: " << rozkaz << "\n"; for (ll maska: v) { //cout << "maska: " << maska << "\n"; if ((maska & ((ll)1 << a[rozkaz])) != 0 && (maska & ((ll)1 << b[rozkaz])) == 0) continue; pom.push_back(maska); if ((maska & ((ll)1 << a[rozkaz])) == 0 && (maska & ((ll)1 << b[rozkaz])) != 0) { ll nowa_maska = maska; nowa_maska ^= ((ll)1 << a[rozkaz]); nowa_maska ^= ((ll)1 << b[rozkaz]); pom.push_back(nowa_maska); } } v.clear(); for (ll maska: pom) v.push_back(maska); } for (ll maska: v) { int ile = 0; for (int i = 1; i <= n; i++) { if ((maska & ((ll)1 << i)) != 0) ile++; } res[ile]++; } for (int i = 1; i <= n; i++) { //cout << res[i] << " "; cout << res[i] % 2 << " "; } cout << "\n"; return 0; } |