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
#include <iostream>

using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
ios_base::sync_with_stdio (false);
    int t;
    cin >> t;

    for(int i=0; i<t; i++)
    {
            int a;
    int sH=10000000000;
    int sW=10000000000;
    int hH=-1;
    int hW=-1;
    int w0=0;
    int w1=0;
    int h0;
    int h1;
    int hPos=-1;
    int wPos=-1;
        cin >> a;
        for(int j=0; j<a; j++)
        {
            cin >> w0;
            cin >> w1;
            cin >> h0;
            cin >> h1;
            if((w0<=sW && w1>=hW)||(w0<sW && w1>=hW)){
            sW=w0;
            hW=w1;
            wPos=j;
            }
            if((h0<=sH && h1>=hH)||(h0<sH && w1>=hH)){
            sH=h0;
            hH=h1;
            hPos=j;
            }
        }
        if(hPos==wPos)
        {
            cout <<"TAK"<<endl;
        }
        else{cout << "NIE"<<endl;
        }
    }
    return 0;
}