#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n, m, q;
cin >> n >> m >> q;
vector<bitset<50000>> tab(n+m+1);
for(int i = 1; i <= n; ++i){
for(int j = i; j <= n; j += i){
tab[i][j-1] = 1;
}
}
for(int i = 1; i <= m; ++i){
int t, a, b;
cin>>t;
if(t == 1){
cin >> a >> b;
tab[n + i] = tab[a] | tab[b];
}else if(t == 2){
cin >> a >> b;
tab[n + i] = tab[a] & tab[b];
}else{
cin >> a;
tab[n + i] = ~tab[a];
}
}
for(int i = 1; i <= q; ++i){
int x, v;
cin >> x >> v;
if(tab[x][v-1])cout<<"TAK\n";
else cout<<"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 | #include <bits/stdc++.h> using namespace std; typedef long long LL; int main(){ cin.tie(0)->sync_with_stdio(0); int n, m, q; cin >> n >> m >> q; vector<bitset<50000>> tab(n+m+1); for(int i = 1; i <= n; ++i){ for(int j = i; j <= n; j += i){ tab[i][j-1] = 1; } } for(int i = 1; i <= m; ++i){ int t, a, b; cin>>t; if(t == 1){ cin >> a >> b; tab[n + i] = tab[a] | tab[b]; }else if(t == 2){ cin >> a >> b; tab[n + i] = tab[a] & tab[b]; }else{ cin >> a; tab[n + i] = ~tab[a]; } } for(int i = 1; i <= q; ++i){ int x, v; cin >> x >> v; if(tab[x][v-1])cout<<"TAK\n"; else cout<<"NIE\n"; } return 0; } |
English