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

using namespace std;

int main() {

    int indeks;
    short n, dodac, tab[15];  
    cin >> n;
    string tekst;

    for (short i = 0; i < 12; i++) {
        tab[i] = 1;
    }
    for (short i = 12; i < 15; i++) {
        tab[i] = 2;
    }

    for (short i = 0; i < n; i++) {
        cin >> tekst;
        //cout << tekst[1] << endl;
        switch (tekst[1]) {
        case 'A': {
            dodac = 1;
            break;
        }
        case 'B': {
            dodac = 2;
            break;
        }
        case 'C': {
            dodac = 3;
            break;
        }
        default:
            break;
        }
        //cout << "dodac =" << dodac << endl;
        // indeks = (int)tekst[0]-48;
        // cout << indeks << endl;
        indeks = (((int)tekst[0]-48)-1)*3+dodac-1;
        //indeks = int(tekst[1]);
        //cout << "indeks = " << indeks << endl;
        tab[indeks]--;
    }
    for (short i = 0; i < 15; i++) {
        if (tab[i] > 0) {
            cout << "NIE";
            return 0;
        }
    }
    cout << "TAK";
    return 0;
}