#include <bits/stdc++.h>
using namespace std;
using bs = bitset<50001>;
int main(){
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int N, M, Q;
cin >> N >> M >> Q;
vector<bs> A(N+M+1);
for(int a = 1; a <= N; a++){
for(int b = a; b <= N; b += a){
A[a][b].flip();
}
}
for(int m = N+1; m <= N+M; m++){
int type;
cin >> type;
if(type == 1){
int x, y;
cin >> x >> y;
A[m] = A[x] | A[y];
} else if(type == 2){
int x, y;
cin >> x >> y;
A[m] = A[x] & A[y];
} else if(type == 3){
int x;
cin >> x;
A[m] = ~A[x];
}
}
for(int q = 0; q < Q; q++){
int x, v;
cin >> x >> v;
cout << (A[x][v] ? "TAK" : "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 | #include <bits/stdc++.h> using namespace std; using bs = bitset<50001>; int main(){ ios_base::sync_with_stdio(false), cin.tie(nullptr); int N, M, Q; cin >> N >> M >> Q; vector<bs> A(N+M+1); for(int a = 1; a <= N; a++){ for(int b = a; b <= N; b += a){ A[a][b].flip(); } } for(int m = N+1; m <= N+M; m++){ int type; cin >> type; if(type == 1){ int x, y; cin >> x >> y; A[m] = A[x] | A[y]; } else if(type == 2){ int x, y; cin >> x >> y; A[m] = A[x] & A[y]; } else if(type == 3){ int x; cin >> x; A[m] = ~A[x]; } } for(int q = 0; q < Q; q++){ int x, v; cin >> x >> v; cout << (A[x][v] ? "TAK" : "NIE") << '\n'; } } |
English