#include <iostream>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> wymiar;
const int MAX_N = 100009;
wymiar max_h[MAX_N];
wymiar min_h[MAX_N];
wymiar max_w[MAX_N];
wymiar min_w[MAX_N];
int wystapienie[MAX_N]={0};
void zerowanie(int n){
for(int i=0; i<n; i++){
//max_h[i].first=max_h[i].second=max_w[i].first=max_w[i].second=0;
//min_h[i].first=min_h[i].second=min_w[i].first=min_w[i].second=0;
wystapienie[i]=0;
}
}
int main(){
ios_base::sync_with_stdio(0);
int z;
cin >> z;
for(int o=0; o<z; o++){
int n;
cin >> n;
for(int i=0; i<n; i++){
int w1, w2, h1, h2;
cin >> w1 >> w2 >> h1 >> h2;
max_h[i].first=h2;
max_w[i].first=w2;
min_h[i].first=h1;
min_w[i].first=w1;
max_h[i].second=i;
max_w[i].second=i;
min_h[i].second=i;
min_w[i].second=i;
}
sort(max_h, max_h+n);
sort(max_w, max_w+n);
sort(min_h, min_h+n);
sort(min_w, min_w+n);
for(int i=0; i<n; i++){
if(min_h[0].first==min_h[i].first){
wystapienie[min_h[i].second]++;
}
if(min_w[0].first==min_w[i].first){
wystapienie[min_w[i].second]++;
}
}
for(int i=n-1; i>=0; i--){
if(max_h[n-1].first==max_h[i].first){
wystapienie[max_h[i].second]++;
}
if(max_w[n-1].first==max_w[i].first){
wystapienie[max_w[i].second]++;
}
}
bool czy=false;
for(int i=0; i<n; i++){
if(wystapienie[i]==4)czy=true;
}
if(czy==true) cout << "TAK" << endl;
else cout << "NIE" << endl;
zerowanie(n);
}
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #include <iostream> #include <algorithm> using namespace std; typedef long double ld; typedef long long ll; typedef pair<ll, ll> wymiar; const int MAX_N = 100009; wymiar max_h[MAX_N]; wymiar min_h[MAX_N]; wymiar max_w[MAX_N]; wymiar min_w[MAX_N]; int wystapienie[MAX_N]={0}; void zerowanie(int n){ for(int i=0; i<n; i++){ //max_h[i].first=max_h[i].second=max_w[i].first=max_w[i].second=0; //min_h[i].first=min_h[i].second=min_w[i].first=min_w[i].second=0; wystapienie[i]=0; } } int main(){ ios_base::sync_with_stdio(0); int z; cin >> z; for(int o=0; o<z; o++){ int n; cin >> n; for(int i=0; i<n; i++){ int w1, w2, h1, h2; cin >> w1 >> w2 >> h1 >> h2; max_h[i].first=h2; max_w[i].first=w2; min_h[i].first=h1; min_w[i].first=w1; max_h[i].second=i; max_w[i].second=i; min_h[i].second=i; min_w[i].second=i; } sort(max_h, max_h+n); sort(max_w, max_w+n); sort(min_h, min_h+n); sort(min_w, min_w+n); for(int i=0; i<n; i++){ if(min_h[0].first==min_h[i].first){ wystapienie[min_h[i].second]++; } if(min_w[0].first==min_w[i].first){ wystapienie[min_w[i].second]++; } } for(int i=n-1; i>=0; i--){ if(max_h[n-1].first==max_h[i].first){ wystapienie[max_h[i].second]++; } if(max_w[n-1].first==max_w[i].first){ wystapienie[max_w[i].second]++; } } bool czy=false; for(int i=0; i<n; i++){ if(wystapienie[i]==4)czy=true; } if(czy==true) cout << "TAK" << endl; else cout << "NIE" << endl; zerowanie(n); } return 0; } |
English