#include <cstdio> #include <algorithm> using namespace std; int read() { int n; scanf("%d", &n); return n; } bool oneCase(int n) { int a, b, c, d, aa, bb, cc, dd; bool res = true; for (int i=0; i<n; ++i) { a = read(); b = read(); c = read(); d = read(); if (i == 0) { aa = a; bb = b; cc = c; dd = d; } else { if (a < aa) aa = a, res = false; if (b > bb) bb = b, res = false; if (c < cc) cc = c, res = false; if (d > dd) dd = d, res = false; res |= a==aa && b==bb && c==cc && d==dd; } } return res; } int main() { int t = read(); while (t--) printf("%s\n", oneCase(read()) ? "TAK" : "NIE"); 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 | #include <cstdio> #include <algorithm> using namespace std; int read() { int n; scanf("%d", &n); return n; } bool oneCase(int n) { int a, b, c, d, aa, bb, cc, dd; bool res = true; for (int i=0; i<n; ++i) { a = read(); b = read(); c = read(); d = read(); if (i == 0) { aa = a; bb = b; cc = c; dd = d; } else { if (a < aa) aa = a, res = false; if (b > bb) bb = b, res = false; if (c < cc) cc = c, res = false; if (d > dd) dd = d, res = false; res |= a==aa && b==bb && c==cc && d==dd; } } return res; } int main() { int t = read(); while (t--) printf("%s\n", oneCase(read()) ? "TAK" : "NIE"); return 0; } |