#include <iostream> #include <algorithm> using namespace std; int main(){ ios_base::sync_with_stdio(0); long long int t, n, w1, w2, h1, h2, minw, maxw, minh, maxh; cin >> t; // ile testow while(t--){ cin >> n; // ile firm bool jest = false; maxh = maxw = 0; minh = minw = 2000000000; while(n--){ cin >> w1 >> w2 >> h1 >> h2; if(minw > w1 || (minw == w1 && !jest)){ minw = w1; if(w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) jest = true; else jest = false; } if(maxw < w2 || (maxw == w2 && !jest)){ maxw = w2; if(w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) jest = true; else jest = false; } if(minh > h1 || (minh == h1 && !jest)){ minh = h1; if(w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) jest = true; else jest = false; } if(maxh < h2 || (maxh == h2 && !jest)){ maxh = h2; if(w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) jest = true; else jest = false; } } if(jest) cout << "TAK" << endl; else cout << "NIE" << endl; } 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 <algorithm> using namespace std; int main(){ ios_base::sync_with_stdio(0); long long int t, n, w1, w2, h1, h2, minw, maxw, minh, maxh; cin >> t; // ile testow while(t--){ cin >> n; // ile firm bool jest = false; maxh = maxw = 0; minh = minw = 2000000000; while(n--){ cin >> w1 >> w2 >> h1 >> h2; if(minw > w1 || (minw == w1 && !jest)){ minw = w1; if(w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) jest = true; else jest = false; } if(maxw < w2 || (maxw == w2 && !jest)){ maxw = w2; if(w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) jest = true; else jest = false; } if(minh > h1 || (minh == h1 && !jest)){ minh = h1; if(w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) jest = true; else jest = false; } if(maxh < h2 || (maxh == h2 && !jest)){ maxh = h2; if(w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) jest = true; else jest = false; } } if(jest) cout << "TAK" << endl; else cout << "NIE" << endl; } return 0; } |