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

using namespace std;

int main() {
    unordered_map<string, int> mapOfOccurrences;
    int numberOfAllExercises;
    string exerciseDivision;
    char divisions[] = {'A', 'B', 'C'};

    for (char division : divisions) {
        for (int i = 1; i <= 5; i++)
            mapOfOccurrences[to_string(i) + division] = 0;
    }

    cin >> numberOfAllExercises;
    for (int i = 0; i < numberOfAllExercises; i++) {
        cin >> exerciseDivision;
        mapOfOccurrences[exerciseDivision]++;
    }

    bool isValid = true;
    for (const auto& key : mapOfOccurrences) {
        if (key.second == 0 || ((key.first == "5A" || key.first == "5B" || key.first == "5C") && key.second < 2))
            isValid = false;
    }

    if (isValid) cout << "TAK";
    else cout << "NIE";

    return 0;
}