#include <stdio.h> int main(){ int t; scanf("%d", &t); int maxWidth, minWidth, maxHeight, minHeight; int maxX,minX,maxY,minY; int offers, bestOffers; for (int i = 0; i < t; i++) { bestOffers = 1; scanf("%d %d %d %d %d", &offers, &minWidth, &maxWidth, &minHeight, &maxHeight); for(int x=1; x<offers; x++){ scanf("%d %d %d %d", &minX, &maxX, &minY, &maxY); if(minX <= minWidth && maxX >= maxWidth && minY <= minHeight && maxY >= maxHeight){ if(minX < minWidth || maxX > maxWidth || minY < minHeight || maxY > maxHeight){ bestOffers = 0; } minWidth = minX; maxWidth = maxX; minHeight = minY; maxHeight = maxY; bestOffers++; } else { if(minX < minWidth){ minWidth = minX; bestOffers = 0; } if(maxX > maxWidth){ maxWidth = maxX; bestOffers = 0; } if(minY < minHeight){ minHeight = minY; bestOffers = 0; } if(maxY > maxHeight){ maxHeight = maxY; bestOffers = 0; } } } if(bestOffers == 0){ printf("NIE\n"); } else { printf("TAK\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 | #include <stdio.h> int main(){ int t; scanf("%d", &t); int maxWidth, minWidth, maxHeight, minHeight; int maxX,minX,maxY,minY; int offers, bestOffers; for (int i = 0; i < t; i++) { bestOffers = 1; scanf("%d %d %d %d %d", &offers, &minWidth, &maxWidth, &minHeight, &maxHeight); for(int x=1; x<offers; x++){ scanf("%d %d %d %d", &minX, &maxX, &minY, &maxY); if(minX <= minWidth && maxX >= maxWidth && minY <= minHeight && maxY >= maxHeight){ if(minX < minWidth || maxX > maxWidth || minY < minHeight || maxY > maxHeight){ bestOffers = 0; } minWidth = minX; maxWidth = maxX; minHeight = minY; maxHeight = maxY; bestOffers++; } else { if(minX < minWidth){ minWidth = minX; bestOffers = 0; } if(maxX > maxWidth){ maxWidth = maxX; bestOffers = 0; } if(minY < minHeight){ minHeight = minY; bestOffers = 0; } if(maxY > maxHeight){ maxHeight = maxY; bestOffers = 0; } } } if(bestOffers == 0){ printf("NIE\n"); } else { printf("TAK\n"); } } } |