#include <bits/stdc++.h>
#define nl '\n'
using namespace std;
const int MAXN = 45e4+1;
vector<bitset<(int)5e4+1>> sets;
int main()
{
cin.tie(0)->sync_with_stdio(0);
int n, m, q;
cin>>n>>m>>q;
sets.resize(n+m+1);
for(int i=1; i<=n; i++){
for(int j=i; j<=n; j+=i){
sets[i][j] = true;
}
}
/*for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
cerr<<sets[i][j]<<' ';
}
cerr<<nl;
}*/
for(int i=n+1; i<=n+m; i++){
int c, x, y;
cin>>c;
if(c == 1){
cin>>x>>y;
sets[i] = sets[x] | sets[y];
}else if(c == 2){
cin>>x>>y;
sets[i] = sets[x] & sets[y];
}else if(c == 3){
cin>>x;
sets[i] = ~sets[x];
}
}
while(q--){
int x, p;
cin>>x>>p;
cout<<(sets[x][p] ? "TAK" : "NIE")<<nl;
}
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 | #include <bits/stdc++.h> #define nl '\n' using namespace std; const int MAXN = 45e4+1; vector<bitset<(int)5e4+1>> sets; int main() { cin.tie(0)->sync_with_stdio(0); int n, m, q; cin>>n>>m>>q; sets.resize(n+m+1); for(int i=1; i<=n; i++){ for(int j=i; j<=n; j+=i){ sets[i][j] = true; } } /*for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ cerr<<sets[i][j]<<' '; } cerr<<nl; }*/ for(int i=n+1; i<=n+m; i++){ int c, x, y; cin>>c; if(c == 1){ cin>>x>>y; sets[i] = sets[x] | sets[y]; }else if(c == 2){ cin>>x>>y; sets[i] = sets[x] & sets[y]; }else if(c == 3){ cin>>x; sets[i] = ~sets[x]; } } while(q--){ int x, p; cin>>x>>p; cout<<(sets[x][p] ? "TAK" : "NIE")<<nl; } return 0; } |
English