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
// Potyczki20201C.cpp
#include <iostream>
#include <string.h>
#include <fstream>
#include <time.h>
#define DEBUG false

using namespace std;


bool task() {
    int n;
    cin >> n;
    string str;
    int tasks[5][3] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} }; // 0-4 rounds, 0,1,2 - A,B,C

    if (n < 18) return false;

    for (int i = 0; i < n; i++) {
        cin >> str;
        if (str.size() != 2) {
            i--;
            continue;
        }
        tasks[str[0] - '1'][str[1] - 'A']++;
    }

    // checking
    for (int i = 0; i < 4; i++) {
        if (tasks[i][0] < 1 || tasks[i][1] < 1 || tasks[i][2] < 1) return false;
    }

    if (tasks[4][0] < 2 || tasks[4][1] < 2 || tasks[4][2] < 2) return false;
    
    return true;
}

void generate() {
    ofstream out("Tests.txt");
    srand(time(0));
    for (int k = 0; k < 10000; k++) {
        int n = rand() % 100 + 1;
        out << n << endl;
        for (int i = 0; i < n; i++) {
            out << rand() % 5 + 1;
            out << char(rand() % 3 + 'A');
            out << " ";
        }
        out << endl;
    }
}

int main()
{
    //generate();
//    for (int k = 0; k < 10000; k++) {
        if (task()) {
            cout << "TAK";
        }
        else cout << "NIE";
//    }
}