#include<iostream> using namespace std; uint64_t mod = 1000000007; int main() { int t; cin>>t; for(int i=0;i<t;i++) { int n; cin>>n; uint64_t sum_1=0,sum_2=0; int64_t highest_a=-1000000000000000000,highest_b=-1000000000000000000; int64_t lowest_a=1000000000000000000,lowest_b=1000000000000000000; for(int j=0;j<n;j++) { int l,a,b; cin>>l>>a>>b; sum_1+=(l*a); sum_2+=(l*b); if(a>highest_a) { highest_a=a; } if(a<lowest_a) { lowest_a=a; } if(b>highest_b) { highest_b=b; } if(b<lowest_b) { lowest_b=b; } sum_1%=mod; sum_2%=mod; //cout<<"sum1: "<<sum_1<<endl; //cout<<"sum2: "<<sum_2<<endl; //<<"highest_a: "<<highest_a<<endl; //cout<<"highest_b: "<<highest_b<<endl; //cout<<"lowest_a: "<<lowest_a<<endl; //cout<<"lowest_b: "<<lowest_b<<endl; } if(sum_1==sum_2) { if(lowest_b<lowest_a || highest_b>highest_a) { cout<<"NIE"; } else { cout<<"TAK"; } } else { cout<<"NIE"; } cout<<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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #include<iostream> using namespace std; uint64_t mod = 1000000007; int main() { int t; cin>>t; for(int i=0;i<t;i++) { int n; cin>>n; uint64_t sum_1=0,sum_2=0; int64_t highest_a=-1000000000000000000,highest_b=-1000000000000000000; int64_t lowest_a=1000000000000000000,lowest_b=1000000000000000000; for(int j=0;j<n;j++) { int l,a,b; cin>>l>>a>>b; sum_1+=(l*a); sum_2+=(l*b); if(a>highest_a) { highest_a=a; } if(a<lowest_a) { lowest_a=a; } if(b>highest_b) { highest_b=b; } if(b<lowest_b) { lowest_b=b; } sum_1%=mod; sum_2%=mod; //cout<<"sum1: "<<sum_1<<endl; //cout<<"sum2: "<<sum_2<<endl; //<<"highest_a: "<<highest_a<<endl; //cout<<"highest_b: "<<highest_b<<endl; //cout<<"lowest_a: "<<lowest_a<<endl; //cout<<"lowest_b: "<<lowest_b<<endl; } if(sum_1==sum_2) { if(lowest_b<lowest_a || highest_b>highest_a) { cout<<"NIE"; } else { cout<<"TAK"; } } else { cout<<"NIE"; } cout<<endl; } return 0; } |