#include <iostream> using namespace std; int main() { int t, n, w1, w2, h1, h2; int w1max, w2max, h1max, h2max, w1current, w2current, h1current, h2current; cin >> t; for (int i=0; i<t; i++) { cin >> n; w1current=1000000001; w2current=0; h1current=1000000001; h2current=0; w1max=1000000001; w2max=0; h1max=1000000001; h2max=0; for (int j=0; j<n; j++) { cin >> w1 >> w2 >> h1 >> h2; if(w1<=w1current && w2>=w2current && h1<=h1current && h2>=h2current) { w1current=w1; w2current=w2; h1current=h1; h2current=h2; } if (h1<h1max) { h1max=h1; } if (h2>h2max) { h2max=h2; } if (w1<w1max) { w1max=w1; } if (w2>w2max) { w2max=w2; } } if (w1current<=w1max && w2current>=w2max && h1current<=h1max && h2current>=h2max) cout << "TAK"; else cout << "NIE"; } }
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 | #include <iostream> using namespace std; int main() { int t, n, w1, w2, h1, h2; int w1max, w2max, h1max, h2max, w1current, w2current, h1current, h2current; cin >> t; for (int i=0; i<t; i++) { cin >> n; w1current=1000000001; w2current=0; h1current=1000000001; h2current=0; w1max=1000000001; w2max=0; h1max=1000000001; h2max=0; for (int j=0; j<n; j++) { cin >> w1 >> w2 >> h1 >> h2; if(w1<=w1current && w2>=w2current && h1<=h1current && h2>=h2current) { w1current=w1; w2current=w2; h1current=h1; h2current=h2; } if (h1<h1max) { h1max=h1; } if (h2>h2max) { h2max=h2; } if (w1<w1max) { w1max=w1; } if (w2>w2max) { w2max=w2; } } if (w1current<=w1max && w2current>=w2max && h1current<=h1max && h2current>=h2max) cout << "TAK"; else cout << "NIE"; } } |