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

using namespace std;

int main() {
    std::ios_base::sync_with_stdio(false);
    int presentCount = 0;
    int presentCat[15] = {0};
    int tasksCount;
    cin >> tasksCount;
    for(int i = 0; i < tasksCount; i ++){
        int division;
        int stage;
        string s;
        cin >> s;
        division = s[1] - ((int)'A');
        stage = s[0] - '0' - 1;
        int catID = stage * 3 + division;
        if(presentCat[catID] == 1 && catID >= 12){
            presentCount ++;
        }
        else if(presentCat[catID] == 0 && catID < 12){
            presentCount ++;
        }
        presentCat[catID] ++;
        if(presentCount == 15) break;
    }
    cout << ((presentCount == 15) ? "TAK" : "NIE") <<"\n";
    return 0;
}