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

using namespace std;

bool maj(unsigned int ** tab, int n);

int main()
{
    int t, n;
    unsigned int *** testy;

    cin >> t;
    testy = new unsigned int ** [t];

    for (int i=0 ; i<t ; i++) {
        cin >> n;
        testy[i] = new unsigned int * [n];
        for (int j=0 ; j<n ; j++) {
            testy[i][j] = new unsigned int[4];
            for (int k=0 ; k<4 ; k++) {
                cin >> testy[i][j][k];
            }
        }
        if (maj(testy[i], n) == true) {
            cout << "TAK" << endl;
        } else {
            cout << "NIE" << endl;
        }
    }

    return 0;
}

bool maj(unsigned int ** tab, int n) {

    for (int i=0 ; i<n ; i++) {
        bool flag = true;
        for (int j=0 ; j<n ; j++) {
            if (tab[i][0] <= tab[j][0] && tab[i][1] >= tab[j][1] && tab[i][2] <= tab[j][2] && tab[i][3] >= tab[j][3]) {
                flag = flag && true;
            } else {
                flag = false;
            }
        }
        if (flag == true) {
            return true;
        }
    }

    return false;
}