#include <iostream> #include <vector> #define INF 2000000000 using namespace std; struct producent { int x1; int x2; int y1; int y2; }; void test() { int n; cin >> n; vector<producent> producenci; int minX = INF, maxX = 0, minY = INF, maxY = 0; int x1, x2, y1, y2; for(int i = 0; i < n; i++) { producent nowy; cin >> x1 >> x2 >> y1 >> y2; if(x1 < minX) minX = x1; if(x2 > maxX) maxX = x2; if(y1 < minY) minY = y1; if(y2 > maxY) maxY = y2; nowy.x1 = x1; nowy.x2 = x2; nowy.y1 = y1; nowy.y2 = y2; producenci.push_back(nowy); } for(int i = 0; i < n; i++) { if(producenci[i].x1 == minX && producenci[i].x2 == maxX && producenci[i].y1 == minY && producenci[i].y2 == maxY) { cout << "TAK" << endl; return; } } cout << "NIE" << endl; } int main() { ios::sync_with_stdio(0); int t; cin >> t; while(t--) { test(); } 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 55 56 57 58 59 | #include <iostream> #include <vector> #define INF 2000000000 using namespace std; struct producent { int x1; int x2; int y1; int y2; }; void test() { int n; cin >> n; vector<producent> producenci; int minX = INF, maxX = 0, minY = INF, maxY = 0; int x1, x2, y1, y2; for(int i = 0; i < n; i++) { producent nowy; cin >> x1 >> x2 >> y1 >> y2; if(x1 < minX) minX = x1; if(x2 > maxX) maxX = x2; if(y1 < minY) minY = y1; if(y2 > maxY) maxY = y2; nowy.x1 = x1; nowy.x2 = x2; nowy.y1 = y1; nowy.y2 = y2; producenci.push_back(nowy); } for(int i = 0; i < n; i++) { if(producenci[i].x1 == minX && producenci[i].x2 == maxX && producenci[i].y1 == minY && producenci[i].y2 == maxY) { cout << "TAK" << endl; return; } } cout << "NIE" << endl; } int main() { ios::sync_with_stdio(0); int t; cin >> t; while(t--) { test(); } return 0; } |