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
/*
 * =====================================================================================
 *
 *       Filename:  wyb.cpp
 *
 *    Description:  Wybór zadań [C]
 *
 *        Version:  0.1.0
 *        Created:  08.12.2020
 *
 *         Author:  Michał Zagórski (zagura), <zagura6@gmail.com>
 *
 * =====================================================================================
 */
#include <cstdio>
#include <iostream>
int main() {
    int n;
    scanf("%d", &n);
    int tasks[16];
    for (int i = 0; i < 16; i++) {
        tasks[i] = 0;
    }
    getchar();
    bool result = true;
    if (n >= 18) {
        for (int i = 0; i < n; i++) {
            char id, league;
            scanf("%c%c ", &id, &league);
//            printf("Read: |%c|%c|\n", id, league);
            int iid, ileague;
            iid = id - '0';
            ileague = (league - 'A') * 5;
//            printf("iid: %d, ileague %d => %d\n", iid, ileague, iid + ileague);
            if (iid + ileague < 16) {
                tasks[iid + ileague] += 1;
            }
        }
    } else {
        result = false;
    }
    for (int i = 1; i < 16; i++) {
//        printf("i: %d - val: %d\n", i, tasks[i]);
        if (tasks[i] == 0) {
            result = false;
            break;
        }
        if (i % 5 == 0) {
            if (tasks[i] < 2) {
                result = false;
                break;
            }
        }
    }
    if (result) {
        printf("TAK\n");
    } else {
        printf("NIE\n");
    }
    return 0;
}