#include <iostream>
#include <string>
const int ROUNDS = 5;
const int DIVISIONS = 3;
struct TaskPool {
int task_count[ROUNDS][DIVISIONS];
void add_task(int round, char division) {
task_count[round - 1][division - 'A'] += 1;
}
bool validate_count() {
for(int i = 0; i < ROUNDS - 1; i++) {
for(int j = 0; j < DIVISIONS; j++) {
if (task_count[i][j] < 1) return false;
}
}
for(int div = 0; div < DIVISIONS; div++) {
if(task_count[ROUNDS - 1][div] < 2) return false;
}
return true;
}
};
int main() {
TaskPool task_pool = {};
int n;
std::cin >> n;
while(n--) {
std::string task;
std::cin >> task;
task_pool.add_task(task[0] - '0', task[1]);
}
if(task_pool.validate_count()) {
std::cout << "TAK" << std::endl;
}
else {
std::cout << "NIE" << std::endl;
}
}
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 | #include <iostream> #include <string> const int ROUNDS = 5; const int DIVISIONS = 3; struct TaskPool { int task_count[ROUNDS][DIVISIONS]; void add_task(int round, char division) { task_count[round - 1][division - 'A'] += 1; } bool validate_count() { for(int i = 0; i < ROUNDS - 1; i++) { for(int j = 0; j < DIVISIONS; j++) { if (task_count[i][j] < 1) return false; } } for(int div = 0; div < DIVISIONS; div++) { if(task_count[ROUNDS - 1][div] < 2) return false; } return true; } }; int main() { TaskPool task_pool = {}; int n; std::cin >> n; while(n--) { std::string task; std::cin >> task; task_pool.add_task(task[0] - '0', task[1]); } if(task_pool.validate_count()) { std::cout << "TAK" << std::endl; } else { std::cout << "NIE" << std::endl; } } |
English