#ifdef _MSC_VER
#ifndef __GNUC__
#pragma warning(disable: 4996)
#endif
#define main main0
#endif
#include <bitset>
#include <iostream>
#include <vector>
using namespace std;
const int MaxZbiorow = 50001;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef vector<bitset<MaxZbiorow>> VectorZbiory;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int n, m, q, f, x, y;
cin >> n >> m >> q;
VectorZbiory vectorZbiory(n + m + 1);
for(int j = 1; j <= n; ++j)
for(int i = 1; i <= n; ++i)
if(i % j == 0)
vectorZbiory[j][i] = 1;
m += n;
for(int j = n + 1; j <= m; ++j) {
cin >> f >> x;
switch(f) {
case 1:
cin >> y;
for(int i = 1; i <= n; ++i)
if(vectorZbiory[x][i] || vectorZbiory[y][i])
vectorZbiory[j][i] = 1;
break;
case 2:
cin >> y;
for(int i = 1; i <= n; ++i)
if(vectorZbiory[x][i] && vectorZbiory[y][i])
vectorZbiory[j][i] = 1;
break;
case 3:
for(int i = 1; i <= n; ++i)
if(!vectorZbiory[x][i])
vectorZbiory[j][i] = 1;
break;
}
}
cin >> x >> y;
cout << (vectorZbiory[x][y] ? "TAK" : "NIE");
for(int j = 1; j < q; ++j) {
cin >> x >> y;
cout << (vectorZbiory[x][y] ? "\nTAK" : "\nNIE");
}
cout.flush();
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 53 54 55 56 57 58 59 60 61 62 63 64 65 | #ifdef _MSC_VER #ifndef __GNUC__ #pragma warning(disable: 4996) #endif #define main main0 #endif #include <bitset> #include <iostream> #include <vector> using namespace std; const int MaxZbiorow = 50001; typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; typedef vector<bitset<MaxZbiorow>> VectorZbiory; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n, m, q, f, x, y; cin >> n >> m >> q; VectorZbiory vectorZbiory(n + m + 1); for(int j = 1; j <= n; ++j) for(int i = 1; i <= n; ++i) if(i % j == 0) vectorZbiory[j][i] = 1; m += n; for(int j = n + 1; j <= m; ++j) { cin >> f >> x; switch(f) { case 1: cin >> y; for(int i = 1; i <= n; ++i) if(vectorZbiory[x][i] || vectorZbiory[y][i]) vectorZbiory[j][i] = 1; break; case 2: cin >> y; for(int i = 1; i <= n; ++i) if(vectorZbiory[x][i] && vectorZbiory[y][i]) vectorZbiory[j][i] = 1; break; case 3: for(int i = 1; i <= n; ++i) if(!vectorZbiory[x][i]) vectorZbiory[j][i] = 1; break; } } cin >> x >> y; cout << (vectorZbiory[x][y] ? "TAK" : "NIE"); for(int j = 1; j < q; ++j) { cin >> x >> y; cout << (vectorZbiory[x][y] ? "\nTAK" : "\nNIE"); } cout.flush(); return 0; } |
English