#include <iostream> using namespace std; int main() { int cases = 0; cin >> cases; for (int i = 0; i < cases; i++) { int elems = 0; cin >> elems; int w1[elems], w2[elems], h1[elems], h2[elems]; for (int j = 0; j < elems; j++) { cin >> w1[j] >> w2[j] >> h1[j] >> h2[j]; } int w1max = 0, w1maxowner = 0, w2max = 0, w2maxowner = 0; int h1max = 0, h1maxowner = 0, h2max = 0, h2maxowner = 0; for (int j = 0; j < elems; j++) { if (w1[j] >= w1max) { w1max = w1[j]; w1maxowner = j; } if (w2[j] >= w2max) { w2max = w2[j]; w2maxowner = j; } if (h1[j] >= h1max) { h1max = h1[j]; h1maxowner = j; } if (h2[j] >= h2max) { h2max = h2[j]; h2maxowner = j; } } if (w1maxowner == h1maxowner && w1maxowner == w2maxowner && h1maxowner == h2maxowner) { cout << "TAK" << endl; } else cout << "NIE" << endl; } }
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 | #include <iostream> using namespace std; int main() { int cases = 0; cin >> cases; for (int i = 0; i < cases; i++) { int elems = 0; cin >> elems; int w1[elems], w2[elems], h1[elems], h2[elems]; for (int j = 0; j < elems; j++) { cin >> w1[j] >> w2[j] >> h1[j] >> h2[j]; } int w1max = 0, w1maxowner = 0, w2max = 0, w2maxowner = 0; int h1max = 0, h1maxowner = 0, h2max = 0, h2maxowner = 0; for (int j = 0; j < elems; j++) { if (w1[j] >= w1max) { w1max = w1[j]; w1maxowner = j; } if (w2[j] >= w2max) { w2max = w2[j]; w2maxowner = j; } if (h1[j] >= h1max) { h1max = h1[j]; h1maxowner = j; } if (h2[j] >= h2max) { h2max = h2[j]; h2maxowner = j; } } if (w1maxowner == h1maxowner && w1maxowner == w2maxowner && h1maxowner == h2maxowner) { cout << "TAK" << endl; } else cout << "NIE" << endl; } } |