#include <cstdio> #include <iostream> #include <utility> #define MP make_pair #define ST first #define ND second using namespace std; int testy, ilosc, w1, w2, h1, h2, pW, kW, pH, kH; bool res; const int INF = 2000000000; pair< pair<int,int>, pair<int,int> > Firmy[1000000]; int main() { scanf("%d", &testy); for(int z = 1; z <= testy; z++) { scanf("%d", &ilosc); kW = kH = 0; pW = pH = INF; res = 0; for(int i = 1; i <= ilosc; i++) { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); pW = min(pW,w1); pH = min(pH,h1); kW = max(kW,w2); kH = max(kH,h2); Firmy[i] = MP(MP(w1,w2),MP(h1,h2)); } for(int i = 1; i <= ilosc; i++) { w1 = Firmy[i].ST.ST; w2 = Firmy[i].ST.ND; h1 = Firmy[i].ND.ST; h2 = Firmy[i].ND.ND; if(w1 == pW && w2 == kW && h1 == pH && h2 == kH) { res = 1; break; } } if(res) printf("TAK\n"); else printf("NIE\n"); } }
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 | #include <cstdio> #include <iostream> #include <utility> #define MP make_pair #define ST first #define ND second using namespace std; int testy, ilosc, w1, w2, h1, h2, pW, kW, pH, kH; bool res; const int INF = 2000000000; pair< pair<int,int>, pair<int,int> > Firmy[1000000]; int main() { scanf("%d", &testy); for(int z = 1; z <= testy; z++) { scanf("%d", &ilosc); kW = kH = 0; pW = pH = INF; res = 0; for(int i = 1; i <= ilosc; i++) { scanf("%d %d %d %d", &w1, &w2, &h1, &h2); pW = min(pW,w1); pH = min(pH,h1); kW = max(kW,w2); kH = max(kH,h2); Firmy[i] = MP(MP(w1,w2),MP(h1,h2)); } for(int i = 1; i <= ilosc; i++) { w1 = Firmy[i].ST.ST; w2 = Firmy[i].ST.ND; h1 = Firmy[i].ND.ST; h2 = Firmy[i].ND.ND; if(w1 == pW && w2 == kW && h1 == pH && h2 == kH) { res = 1; break; } } if(res) printf("TAK\n"); else printf("NIE\n"); } } |