#include <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 50007;
constexpr int MAXM = 400007;
constexpr int MAXNM = MAXN+MAXM;
vector<bitset<MAXN>> bit;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, m, q;
cin >> n >> m >> q;
bit.resize(n+m);
for (int i = 0; i < n; ++i) {
for (int j = i; j < n; j += (i+1)) {
bit[i].set(j, 1);
}
}
for (int i = n; i < n+m; ++i) {
int t, a, b;
cin >> t;
if (t == 1) {
cin >> a >> b;
--a, --b;
bit[i] = bit[a]|bit[b];
} else if (t == 2) {
cin >> a >> b;
--a, --b;
bit[i] = bit[a]&bit[b];
} else if (t == 3) {
cin >> a;
--a;
bit[i] = ~bit[a];
}
}
while (q--) {
int x, v;
cin >> x >> v;
--x;
--v;
bool res = bit[x][v];
cout << (res ? "TAK\n" : "NIE\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 | #include <bits/stdc++.h> using namespace std; constexpr int MAXN = 50007; constexpr int MAXM = 400007; constexpr int MAXNM = MAXN+MAXM; vector<bitset<MAXN>> bit; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m, q; cin >> n >> m >> q; bit.resize(n+m); for (int i = 0; i < n; ++i) { for (int j = i; j < n; j += (i+1)) { bit[i].set(j, 1); } } for (int i = n; i < n+m; ++i) { int t, a, b; cin >> t; if (t == 1) { cin >> a >> b; --a, --b; bit[i] = bit[a]|bit[b]; } else if (t == 2) { cin >> a >> b; --a, --b; bit[i] = bit[a]&bit[b]; } else if (t == 3) { cin >> a; --a; bit[i] = ~bit[a]; } } while (q--) { int x, v; cin >> x >> v; --x; --v; bool res = bit[x][v]; cout << (res ? "TAK\n" : "NIE\n"); } return 0; } |
English