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

const int RUNDY = 5;
const int KATEGORIE = 3;

int main() {
    int n;
    std::cin >> n;
    char zadania[RUNDY][KATEGORIE];
    for (int i = 0; i < RUNDY; ++i) {
        for (int j = 0; j < KATEGORIE; ++j) {
            zadania[i][j] = 0;
        }
    }
    int suma = 0;
    for (int i = 0; i < n; ++i) {
        int r;
        char k;
        std::cin >> r >> k;
        if (r == RUNDY) {
            if(zadania[r-1][k - 'A'] < 2) {
                zadania[r-1][k - 'A']++;
                suma++;
            }
        }
        else {
            if(zadania[r-1][k - 'A'] < 1) {
                zadania[r-1][k - 'A']++;
                suma++;
            }
        }
        if(suma == KATEGORIE*(RUNDY + 1)) {
            std::cout << "TAK\n";
            return 0;
        }
    }
    std::cout << "NIE\n";
    return 0;
}