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
#include <iostream>
using namespace std;
char sprawdzenie(short n, char *tab, char c)
{
    short i;
    short t[5];
    t[4] = 0;
    for (i = 1; i < 2 * n; i = i + 2)
    {
        if (tab[i] == c)
        {
            switch (tab[i - 1])
            {
            case '1': t[0] = 1;
                break;
            case '2': t[1] = 1;
                break;
            case '3': t[2] = 1;
                break;
            case '4': t[3] = 1;
                break;
            case '5': t[4] = t[4] + 1;
                break;
            }
        }
        if (t[0] == 1 && t[1] == 1 && t[2] == 1 && t[3] == 1 && t[4] > 1)
            break;
    }
    if (t[0] == 1 && t[1] == 1 && t[2] == 1 && t[3] == 1 && t[4] > 1)
        return 'T';
    else
        return 'N';
}
int main()
{
    short n, i = 0;
    cin >> n;
    char* tab = new char[2*n];
    while (i < 2 * n)
    {
        cin >> tab[i] >> tab[i + 1];
        cout << " ";
        i = i + 2;
    }
    if (n < 18)
        cout << "NIE";
    else
    {
        char c1 = 'A';
        char c2 = 'B';
        char c3 = 'C';
        if (sprawdzenie(n, tab, c1) == 'T' && sprawdzenie(n, tab, c2) == 'T' && sprawdzenie(n, tab, c3) == 'T')
            cout << "TAK";
        else
            cout << "NIE";
    }
    delete[] tab;
    return 0;
}