#include <iostream> #include <queue> #include <deque> #include <algorithm> using namespace std; typedef unsigned long UL; typedef unsigned long long ULL; #define FOR(i,a,b) for(int i=a;i<b;i++) int main() { int n, m; scanf("%d",&n); FOR(i,0,n) { scanf("%d",&m); int W1,W2,H1,H2; int w1,w2,h1,h2; scanf("%d %d %d %d",&W1,&W2,&H1,&H2); bool TAK = false; FOR(j,1,m) { scanf("%d %d %d %d",&w1,&w2,&h1,&h2); bool ntak = false; if (w1 <= W1 && w2 >= W2 && h1 <= H1 && h2 >= H2) ntak = true; if (w1 < W1 || w2 > W2 || h1 < H1 || h2 > H2) TAK = false; if (w1 < W1) W1 = w1; if (w2 > W2) W2 = w2; if (h1 < H1) H1 = h1; if (h2 > H2) H2 = h2; if (ntak) TAK = true; } if (TAK) printf("TAK\n"); else printf("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 | #include <iostream> #include <queue> #include <deque> #include <algorithm> using namespace std; typedef unsigned long UL; typedef unsigned long long ULL; #define FOR(i,a,b) for(int i=a;i<b;i++) int main() { int n, m; scanf("%d",&n); FOR(i,0,n) { scanf("%d",&m); int W1,W2,H1,H2; int w1,w2,h1,h2; scanf("%d %d %d %d",&W1,&W2,&H1,&H2); bool TAK = false; FOR(j,1,m) { scanf("%d %d %d %d",&w1,&w2,&h1,&h2); bool ntak = false; if (w1 <= W1 && w2 >= W2 && h1 <= H1 && h2 >= H2) ntak = true; if (w1 < W1 || w2 > W2 || h1 < H1 || h2 > H2) TAK = false; if (w1 < W1) W1 = w1; if (w2 > W2) W2 = w2; if (h1 < H1) H1 = h1; if (h2 > H2) H2 = h2; if (ntak) TAK = true; } if (TAK) printf("TAK\n"); else printf("NIE\n"); } return 0; } |