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
#include <stdio.h>
using namespace std;

int main(int argc, char** argv) {
    char amountOfAuctions, auctionID;
    int amountOfMirrorCompanies, mirrorCompanyID;
    int globallyMinWidth, globallyMaxWidth, globallyMinHeight, globallyMaxHeight;
    int minWidth, maxWidth, minHeight, maxHeight;
    bool dominantExists;
    char boundariesReached;
    bool wereBoundariesBroken;
    
    scanf("%hhd",&amountOfAuctions);
    for (auctionID = 0; auctionID < amountOfAuctions; auctionID++){
        globallyMinWidth = 1000000000; 
        globallyMaxWidth = 1; 
        globallyMinHeight = 1000000000; 
        globallyMaxHeight = 1;
        
        scanf("%d",&amountOfMirrorCompanies);
        for(mirrorCompanyID = 0; mirrorCompanyID < amountOfMirrorCompanies; mirrorCompanyID++){
            boundariesReached = 0;
            wereBoundariesBroken = false;
            
            scanf("%d %d %d %d",&minWidth,&maxWidth,&minHeight,&maxHeight);
            
            if(minWidth <= globallyMinWidth){
                boundariesReached++;
                if(minWidth < globallyMinWidth){
                    wereBoundariesBroken = true;
                    globallyMinWidth = minWidth;
                }
            }
            if(maxWidth >= globallyMaxWidth){
                boundariesReached++;
                if(maxWidth > globallyMaxWidth){
                    wereBoundariesBroken = true;
                    globallyMaxWidth = maxWidth;
                }
            }
            if(minHeight <= globallyMinHeight){
                boundariesReached++;
                if(minHeight < globallyMinHeight){
                    wereBoundariesBroken = true;
                    globallyMinHeight = minHeight;
                }
            }
            if(maxHeight >= globallyMaxHeight){
                boundariesReached++;
                if(maxHeight > globallyMaxHeight){
                    wereBoundariesBroken = true;
                    globallyMaxHeight = maxHeight;
                }
            }
            
            if(boundariesReached > 0){
                if(boundariesReached == 4){
                    dominantExists = true;
                }
                else if(wereBoundariesBroken){ //as boundaries reached < 4, for sure boundaries broken are also < 4
                    dominantExists = false;
                }
            }
        }
        
        if(dominantExists){
            printf("TAK\n");
        }
        else{
            printf("NIE\n");
        } 
    }
    return 0;
}