#include <iostream>
#include <vector>
int tab[100005][4];
using namespace std;
int t, n;
int wmin,wmax,hmin,hmax;
int main()
{
ios_base::sync_with_stdio(0);
cin >> t;
for(int i = 0; i < t; i++)
{
cin >> n;
for(int j = 0; j < n; j++)
{
cin >> tab[j][0] >> tab[j][1] >> tab[j][2] >> tab[j][3];
}
wmin = 2000000000;
wmax = 0;
hmin = 2000000000;
hmax = 0;
bool warunek = false;
for(int j = 0; j < n; j++)
{
if(tab[j][0] < wmin)
{
wmin = tab[j][0];
warunek = false;
}
if(tab[j][1] > wmax)
{
wmax = tab[j][1];
warunek = false;
}
if(tab[j][2] < hmin)
{
hmin = tab[j][2];
warunek = false;
}
if(tab[j][3] > hmax)
{
hmax = tab[j][3];
warunek = false;
}
if((tab[j][0] <= wmin) && (tab[j][1] >= wmax) && (tab[j][2] <= hmin) && (tab[j][3] >= hmax))
{
warunek = true;
}
}
if(warunek == true)
{
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #include <iostream> #include <vector> int tab[100005][4]; using namespace std; int t, n; int wmin,wmax,hmin,hmax; int main() { ios_base::sync_with_stdio(0); cin >> t; for(int i = 0; i < t; i++) { cin >> n; for(int j = 0; j < n; j++) { cin >> tab[j][0] >> tab[j][1] >> tab[j][2] >> tab[j][3]; } wmin = 2000000000; wmax = 0; hmin = 2000000000; hmax = 0; bool warunek = false; for(int j = 0; j < n; j++) { if(tab[j][0] < wmin) { wmin = tab[j][0]; warunek = false; } if(tab[j][1] > wmax) { wmax = tab[j][1]; warunek = false; } if(tab[j][2] < hmin) { hmin = tab[j][2]; warunek = false; } if(tab[j][3] > hmax) { hmax = tab[j][3]; warunek = false; } if((tab[j][0] <= wmin) && (tab[j][1] >= wmax) && (tab[j][2] <= hmin) && (tab[j][3] >= hmax)) { warunek = true; } } if(warunek == true) { cout <<"TAK\n"; } else { cout <<"NIE\n"; } } return 0; } |
English