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
#include<iostream>
using namespace std;
int main()
{
    int n, i;
    string tab[100];
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> tab[i];
    }
    if (n < 18) cout<<"NIE";
    else
    {
        int counter_tab[5][3] = {0}, counter = 0, task, division;
        i = 0;
        do
        {
            task = int(tab[i][0] - 48) - 1;
            division = int(tab[i][1] - 65);
            if (task < 4)
            {
                if (counter_tab[task][division] == 0)
                {
                    counter++;
                    counter_tab[task][division] = 1;
                }
            }
            else if (counter_tab[task][division] < 2)
            {
                counter++;
                counter_tab[task][division]++;
            }
            i++;
        }
        while (i < n && counter < 18);
        if (counter == 18) cout<<"TAK";
        else cout<<"NIE";
    }
    return 0;
}