#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
const int N = 36;
const int M = 1000;
pair <int, int> ruch[M + 1];
bool policz(bitset <N> &x, int r) {
if(r == 0)
return 1;
//1 0 = esc
if(x.test(ruch[r].fi) && !x.test(ruch[r].se))
return 0;
//0 1 = 2 przypadki (zamien i nie zamieniaj)
if(!x.test(ruch[r].fi) && x.test(ruch[r].se)) {
bitset <N> nowy = x;
nowy.flip(ruch[r].fi);
nowy.flip(ruch[r].se);
return policz(nowy, r - 1) ^ policz(x, r - 1);
}
//pozostale = to samo z r - 1
return policz(x, r - 1);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
for(int i = 1; i <= m; i++)
cin >> ruch[i].fi >> ruch[i].se;
//bool x = 1;
//x += 1;
//cout << x << "\n";
for(int k = 1; k <= n; k++) {
bool odp = 0;
for(int i = 1; i <= n - k + 1; i++) {
bitset <N> liczba;
for(int idx = i; idx < i + k; idx++) {
liczba.flip(idx);
}
odp ^= policz(liczba, m);
//bool nowy = policz(liczba, m);
//cout << liczba << " " << nowy << "\n";
//odp ^= nowy;
}
cout << odp << " ";
}
cout << "\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 57 58 59 60 61 62 63 | #include <bits/stdc++.h> using namespace std; #define fi first #define se second typedef long long ll; const int N = 36; const int M = 1000; pair <int, int> ruch[M + 1]; bool policz(bitset <N> &x, int r) { if(r == 0) return 1; //1 0 = esc if(x.test(ruch[r].fi) && !x.test(ruch[r].se)) return 0; //0 1 = 2 przypadki (zamien i nie zamieniaj) if(!x.test(ruch[r].fi) && x.test(ruch[r].se)) { bitset <N> nowy = x; nowy.flip(ruch[r].fi); nowy.flip(ruch[r].se); return policz(nowy, r - 1) ^ policz(x, r - 1); } //pozostale = to samo z r - 1 return policz(x, r - 1); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; for(int i = 1; i <= m; i++) cin >> ruch[i].fi >> ruch[i].se; //bool x = 1; //x += 1; //cout << x << "\n"; for(int k = 1; k <= n; k++) { bool odp = 0; for(int i = 1; i <= n - k + 1; i++) { bitset <N> liczba; for(int idx = i; idx < i + k; idx++) { liczba.flip(idx); } odp ^= policz(liczba, m); //bool nowy = policz(liczba, m); //cout << liczba << " " << nowy << "\n"; //odp ^= nowy; } cout << odp << " "; } cout << "\n"; } |
English