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
#include <iostream>
#include<map>
#include <vector>
#include <sstream>
#include <iterator>
using namespace std;

int main() {
    map<string, int> tasks;
    vector<string> characters = {"A", "B", "C"};

    for (const auto& ch: characters){
        for (int i = 1; i<=5; i++){
            string new_key;
            new_key.append(std::to_string(i));
            new_key.append(ch);

            tasks[new_key] = 0;
        }
    }

    string max_len;
    getline(cin, max_len);

    string all_tasks;
    getline(cin, all_tasks);

    istringstream iss(all_tasks);
    vector<string> poss_solutions{istream_iterator<string>{iss},
                          istream_iterator<string>{}};

    for (const auto& task: poss_solutions) {
        if (tasks.count(task) > 0){
            tasks[task] += 1;
        }
    }

    bool result = true;
    for (const auto& pair: tasks) {
        string key = pair.first;
        int counter = pair.second;
        if (key.find('5') != std::string::npos) {
            if (counter < 2){
                result = false;
                break;
            }
        }
        else {
            if (counter < 1){
                result = false;
                break;
            }
        }
    }
    if (result) {
        cout << "TAK";
    }
    else {
        cout << "NIE";
    }
    return 0;
}