#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int t, n;
int max_h, min_h, max_w, min_w;
int pom_max_h, pom_min_h, pom_max_w, pom_min_w;
bool ok,change;
//Przypadki testowe
scanf("%d",&t);
while(t>0)
{
//Init
scanf("%d",&n);
ok=true;
scanf("%d",&min_h);
scanf("%d",&max_h);
scanf("%d",&min_w);
scanf("%d",&max_w);
n--;
//Dane po kolei
while(n>0)
{
change=false;
scanf("%d",&pom_min_h);
if(pom_min_h<min_h)
{
change=true;
min_h=pom_min_h;
}
scanf("%d",&pom_max_h);
if(pom_max_h>max_h)
{
change=true;
max_h=pom_max_h;
}
scanf("%d",&pom_min_w);
if(pom_min_w<min_w)
{
change=true;
min_w=pom_min_w;
}
scanf("%d",&pom_max_w);
if(pom_max_w>max_w)
{
change=true;
max_w=pom_max_w;
}
//Checking!
if(min_h==pom_min_h&&min_w==pom_min_w&&max_h==pom_max_h&&max_w==pom_max_w)ok=true;
if(change==true)
{
if(min_h==pom_min_h&&min_w==pom_min_w&&max_h==pom_max_h&&max_w==pom_max_w)ok=true;
else ok=false;
}
n--;
}
if(ok==true) printf("TAK\n");
else printf("NIE\n");
t--;
}
}
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 67 68 69 70 71 72 73 74 75 76 77 78 79 | #include<cstdio> #include<iostream> using namespace std; int main() { int t, n; int max_h, min_h, max_w, min_w; int pom_max_h, pom_min_h, pom_max_w, pom_min_w; bool ok,change; //Przypadki testowe scanf("%d",&t); while(t>0) { //Init scanf("%d",&n); ok=true; scanf("%d",&min_h); scanf("%d",&max_h); scanf("%d",&min_w); scanf("%d",&max_w); n--; //Dane po kolei while(n>0) { change=false; scanf("%d",&pom_min_h); if(pom_min_h<min_h) { change=true; min_h=pom_min_h; } scanf("%d",&pom_max_h); if(pom_max_h>max_h) { change=true; max_h=pom_max_h; } scanf("%d",&pom_min_w); if(pom_min_w<min_w) { change=true; min_w=pom_min_w; } scanf("%d",&pom_max_w); if(pom_max_w>max_w) { change=true; max_w=pom_max_w; } //Checking! if(min_h==pom_min_h&&min_w==pom_min_w&&max_h==pom_max_h&&max_w==pom_max_w)ok=true; if(change==true) { if(min_h==pom_min_h&&min_w==pom_min_w&&max_h==pom_max_h&&max_w==pom_max_w)ok=true; else ok=false; } n--; } if(ok==true) printf("TAK\n"); else printf("NIE\n"); t--; } } |
English