#include <iostream>
#include <stdio.h>
using namespace std;
long long t,n,l,a,b,x,y,q,z,q1=1e18,z1=1e18;
long long wy;
char ch;
bool bb;
long long fastread ()
{
wy=0;
bb=false;
ch=getchar();
if (ch=='-')
{
bb=true;
ch=getchar();
}
while (ch>='0'&&ch<='9')
{
wy*=10;
wy+=int(ch)-48;
ch=getchar();
}
if (bb)
return -wy;
return wy;
}
int main()
{
t=fastread();
for(int j=0; j<t; j++)
{
long long oilemax,oilemin,ailemax,ailemin,c=0;
n=fastread();
for(int i=0; i<n; i++)
{
l=fastread();
a=fastread();
b=fastread();
if(a!=b)
{
x+=l*a;
y+=l*b;
if(a>z)
{
z=a;
oilemax=l;
}
if(a==z)
{
oilemax+=l;
}
if(b>q)
{
q=b;
ailemax=l;
}
if(b==q)
{
ailemax+=l;
}
if(a<z1)
{
z1=a;
oilemin=l;
}
if(a==z1)
{
oilemin+=l;
}
if(b<q1)
{
q1=b;
ailemin=l;
}
if(a==z)
{
ailemin+=l;
}
}
}
if(z1==q1&&oilemin<ailemin)
{
c=1;
}
if(z==q&&oilemax<ailemax)
{
c=1;
}
if(x==y&&q1>=z1&&q<=z&&c==0)
{
cout<<"TAK"<<endl;
}
else
cout<<"NIE"<<endl;
x=0;
y=0;
z=0;
q=0;
q1=1e18;
z1=1e18;
oilemax=0;oilemin=0;ailemax=0;ailemin=0;
c=0;
}
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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | #include <iostream> #include <stdio.h> using namespace std; long long t,n,l,a,b,x,y,q,z,q1=1e18,z1=1e18; long long wy; char ch; bool bb; long long fastread () { wy=0; bb=false; ch=getchar(); if (ch=='-') { bb=true; ch=getchar(); } while (ch>='0'&&ch<='9') { wy*=10; wy+=int(ch)-48; ch=getchar(); } if (bb) return -wy; return wy; } int main() { t=fastread(); for(int j=0; j<t; j++) { long long oilemax,oilemin,ailemax,ailemin,c=0; n=fastread(); for(int i=0; i<n; i++) { l=fastread(); a=fastread(); b=fastread(); if(a!=b) { x+=l*a; y+=l*b; if(a>z) { z=a; oilemax=l; } if(a==z) { oilemax+=l; } if(b>q) { q=b; ailemax=l; } if(b==q) { ailemax+=l; } if(a<z1) { z1=a; oilemin=l; } if(a==z1) { oilemin+=l; } if(b<q1) { q1=b; ailemin=l; } if(a==z) { ailemin+=l; } } } if(z1==q1&&oilemin<ailemin) { c=1; } if(z==q&&oilemax<ailemax) { c=1; } if(x==y&&q1>=z1&&q<=z&&c==0) { cout<<"TAK"<<endl; } else cout<<"NIE"<<endl; x=0; y=0; z=0; q=0; q1=1e18; z1=1e18; oilemax=0;oilemin=0;ailemax=0;ailemin=0; c=0; } return 0; } |
English