#include <algorithm> #include <cstdio> using namespace std; const int MAXN = 100005; int n; struct lustro { pair<int, int> height; pair<int, int> width; } tab[MAXN]; void wczytaj() { scanf("%d", &n); for(int i = 0; i < n; ++i) { scanf("%d %d %d %d", &tab[i].height.first, &tab[i].height.second, &tab[i].width.first, &tab[i].width.second); } } bool isWinner() { int firstMinHeight, firstMaxHeight, firstMinWidth, firstMaxWidth; firstMinHeight = tab[0].height.first; firstMaxHeight = tab[0].height.second; firstMinWidth = tab[0].width.first; firstMaxWidth = tab[0].width.second; for(int i = 1; i < n; ++i){ if(firstMinHeight > tab[i].height.first) firstMinHeight = tab[i].height.first; if(firstMaxHeight < tab[i].height.second) firstMaxHeight = tab[i].height.second; if(firstMinWidth > tab[i].width.first) firstMinWidth = tab[i].width.first; if(firstMaxWidth < tab[i].width.second) firstMaxWidth = tab[i].width.second; } for(int i = 0; i < n; ++i) if(tab[i].height.first == firstMinHeight && tab[i].height.second == firstMaxHeight && tab[i].width.first == firstMinWidth && tab[i].width.second == firstMaxWidth) return true; return false; } int main() { int t; scanf("%d", &t); while(t--){ wczytaj(); isWinner() ? printf("TAK\n") : 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 54 | #include <algorithm> #include <cstdio> using namespace std; const int MAXN = 100005; int n; struct lustro { pair<int, int> height; pair<int, int> width; } tab[MAXN]; void wczytaj() { scanf("%d", &n); for(int i = 0; i < n; ++i) { scanf("%d %d %d %d", &tab[i].height.first, &tab[i].height.second, &tab[i].width.first, &tab[i].width.second); } } bool isWinner() { int firstMinHeight, firstMaxHeight, firstMinWidth, firstMaxWidth; firstMinHeight = tab[0].height.first; firstMaxHeight = tab[0].height.second; firstMinWidth = tab[0].width.first; firstMaxWidth = tab[0].width.second; for(int i = 1; i < n; ++i){ if(firstMinHeight > tab[i].height.first) firstMinHeight = tab[i].height.first; if(firstMaxHeight < tab[i].height.second) firstMaxHeight = tab[i].height.second; if(firstMinWidth > tab[i].width.first) firstMinWidth = tab[i].width.first; if(firstMaxWidth < tab[i].width.second) firstMaxWidth = tab[i].width.second; } for(int i = 0; i < n; ++i) if(tab[i].height.first == firstMinHeight && tab[i].height.second == firstMaxHeight && tab[i].width.first == firstMinWidth && tab[i].width.second == firstMaxWidth) return true; return false; } int main() { int t; scanf("%d", &t); while(t--){ wczytaj(); isWinner() ? printf("TAK\n") : printf("NIE\n"); } } |