#include "bits/stdc++.h"
using namespace std;
constexpr int MAXN = 100001;
using bs = bitset<MAXN>;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m, q;
cin >> n >> m >> q;
vector <bs> v(n + m + 1);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (j % i == 0) {
v[i][j] = 1;
}
}
}
for (int i = 1; i <= m; i++) {
int o;
cin >> o;
if (o == 1) {
int x, y;
cin >> x >> y;
v[n + i] = v[x] | v[y];
} else if (o == 2) {
int x, y;
cin >> x >> y;
v[n + i] = v[x] & v[y];
} else {
int x;
cin >> x;
v[n + i] = ~v[x];
}
}
while (q--) {
int x, y;
cin >> x >> y;
cout << (v[x][y] ? "TAK\n" : "NIE\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 | #include "bits/stdc++.h" using namespace std; constexpr int MAXN = 100001; using bs = bitset<MAXN>; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, q; cin >> n >> m >> q; vector <bs> v(n + m + 1); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (j % i == 0) { v[i][j] = 1; } } } for (int i = 1; i <= m; i++) { int o; cin >> o; if (o == 1) { int x, y; cin >> x >> y; v[n + i] = v[x] | v[y]; } else if (o == 2) { int x, y; cin >> x >> y; v[n + i] = v[x] & v[y]; } else { int x; cin >> x; v[n + i] = ~v[x]; } } while (q--) { int x, y; cin >> x >> y; cout << (v[x][y] ? "TAK\n" : "NIE\n"); } } |
English