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;

int main(){

    unsigned short i, j;
    unsigned short ilosc_przypadkow;
    unsigned long int w1, w2, h1, h2;
    unsigned long int extreme_w1, extreme_w2, extreme_h1, extreme_h2;
    char det_w1, det_w2, det_h1, det_h2;
    bool a;
    bool b;
    bool is_major;

    cin >> ilosc_przypadkow;
    unsigned int *przypadki = new unsigned int[ilosc_przypadkow];
    for (i=0; i<ilosc_przypadkow; ++i){
        cin >> przypadki[i];
        for (j=0; j<przypadki[i]; ++j){
            cin >> w1;
            cin >> w2;
            cin >> h1;
            cin >> h2;
            if (j == 0){
                extreme_w1 = w1;
                extreme_w2 = w2;
                extreme_h1 = h1;
                extreme_h2 = h2;
                is_major = true;
            }
            else{
                if (w1 < extreme_w1){
                    extreme_w1 = w1;
                    det_w1 = 1;
                }
                else if (w1 == extreme_w1) det_w1 = 0;
                else det_w1 = -1;
                if (w2 > extreme_w2){
                    extreme_w2 = w2;
                    det_w2 = 1;
                }
                else if (w2 == extreme_w2) det_w2 = 0;
                else det_w2 = -1;
                if (h1 < extreme_h1){
                    extreme_h1 = h1;
                    det_h1 = 1;
                }
                else if (h1 == extreme_w1) det_h1 = 0;
                else det_h1 = -1;
                if (h2 > extreme_h2){
                    extreme_h2 = h2;
                    det_h2 = 1;
                }
                else if (h2 == extreme_h2) det_h2 = 0;
                else det_h2 = -1;
                a = (det_w1>-1 && det_w2>-1 && det_h1>-1 && det_h2>-1 ? true : false);
                b = (det_w1<1 && det_w2<1 && det_h1<1 && det_h2<1 ? true : false);
                is_major = a | b;
            }
        }
        cout << (is_major == true ? "TAK" : "NIE") << endl;
    }

    delete[] przypadki;

    return 0;
}