#include <iostream> using namespace std; int main() { long long n; cin>>n; for(long long i=0;i<n;i++) { long long x1,x2,x3,x4; long long a,b,c,d; long long flag=0; long long m; cin>>m; cin>>x1>>x2>>x3>>x4; a=x1*x3; b=x2*x4; for(long long j=0;j<m-1;j++) { cin>>x1>>x2>>x3>>x4; c=x1*x3; d=x2*x4; if(c<=a&&d>=b){a=c;b=d;flag=0;} else if((c>a&&d>b)||(c<a&&d<b)){ a=min(a,c); b=max(d,b); flag++; } } if(flag==0)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 | #include <iostream> using namespace std; int main() { long long n; cin>>n; for(long long i=0;i<n;i++) { long long x1,x2,x3,x4; long long a,b,c,d; long long flag=0; long long m; cin>>m; cin>>x1>>x2>>x3>>x4; a=x1*x3; b=x2*x4; for(long long j=0;j<m-1;j++) { cin>>x1>>x2>>x3>>x4; c=x1*x3; d=x2*x4; if(c<=a&&d>=b){a=c;b=d;flag=0;} else if((c>a&&d>b)||(c<a&&d<b)){ a=min(a,c); b=max(d,b); flag++; } } if(flag==0)cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } } |