#include <iostream> #include <vector> #include <string> enum task_number { A1 = 0, A2, A3, A4, A5, B1 = 6, B2, B3, B4, B5, C1 = 12, C2, C3, C4, C5 }; task_number map(std::string task_string_id) { task_number task_number_id; if (task_string_id == "1A") { task_number_id = task_number::A1; } else if (task_string_id == "2A") { task_number_id = task_number::A2; } else if (task_string_id == "3A") { task_number_id = task_number::A3; } else if (task_string_id == "4A") { task_number_id = task_number::A4; } else if (task_string_id == "5A") { task_number_id = task_number::A5; } else if (task_string_id == "1B") { task_number_id = task_number::B1; } else if (task_string_id == "2B") { task_number_id = task_number::B2; } else if (task_string_id == "3B") { task_number_id = task_number::B3; } else if (task_string_id == "4B") { task_number_id = task_number::B4; } else if (task_string_id == "5B") { task_number_id = task_number::B5; } else if (task_string_id == "1C") { task_number_id = task_number::C1; } else if (task_string_id == "2C") { task_number_id = task_number::C2; } else if (task_string_id == "3C") { task_number_id = task_number::C3; } else if (task_string_id == "4C") { task_number_id = task_number::C4; } else if (task_string_id == "5C") { task_number_id = task_number::C5; } return task_number_id; } int main() { constexpr int ALL_TASKS_COUNT = 18; int filled_tasks = 0; std::vector<bool> present_tasks(ALL_TASKS_COUNT, false); int ideas_amount; std::cin >> ideas_amount; if (ideas_amount < 18) { std::cout << "NIE"; return 0; } std::string task_list_string; getchar(); std::getline(std::cin, task_list_string); for (auto i = 0; i < task_list_string.size(); i = i+3 ) { auto task_string_id = task_list_string.substr(i, 2); auto task_id = map(task_string_id); if (!present_tasks[task_id]) { present_tasks[task_id] = true; filled_tasks = filled_tasks + 1; } else { if (task_id == task_number::A5 || task_id == task_number::B5 || task_id == task_number::C5) { if (!present_tasks[task_id + 1]) { present_tasks[task_id + 1] = true; filled_tasks = filled_tasks + 1; } } } if (filled_tasks == ALL_TASKS_COUNT) { std::cout << "TAK"; return 0; } } std::cout << "NIE"; return 0; }
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | #include <iostream> #include <vector> #include <string> enum task_number { A1 = 0, A2, A3, A4, A5, B1 = 6, B2, B3, B4, B5, C1 = 12, C2, C3, C4, C5 }; task_number map(std::string task_string_id) { task_number task_number_id; if (task_string_id == "1A") { task_number_id = task_number::A1; } else if (task_string_id == "2A") { task_number_id = task_number::A2; } else if (task_string_id == "3A") { task_number_id = task_number::A3; } else if (task_string_id == "4A") { task_number_id = task_number::A4; } else if (task_string_id == "5A") { task_number_id = task_number::A5; } else if (task_string_id == "1B") { task_number_id = task_number::B1; } else if (task_string_id == "2B") { task_number_id = task_number::B2; } else if (task_string_id == "3B") { task_number_id = task_number::B3; } else if (task_string_id == "4B") { task_number_id = task_number::B4; } else if (task_string_id == "5B") { task_number_id = task_number::B5; } else if (task_string_id == "1C") { task_number_id = task_number::C1; } else if (task_string_id == "2C") { task_number_id = task_number::C2; } else if (task_string_id == "3C") { task_number_id = task_number::C3; } else if (task_string_id == "4C") { task_number_id = task_number::C4; } else if (task_string_id == "5C") { task_number_id = task_number::C5; } return task_number_id; } int main() { constexpr int ALL_TASKS_COUNT = 18; int filled_tasks = 0; std::vector<bool> present_tasks(ALL_TASKS_COUNT, false); int ideas_amount; std::cin >> ideas_amount; if (ideas_amount < 18) { std::cout << "NIE"; return 0; } std::string task_list_string; getchar(); std::getline(std::cin, task_list_string); for (auto i = 0; i < task_list_string.size(); i = i+3 ) { auto task_string_id = task_list_string.substr(i, 2); auto task_id = map(task_string_id); if (!present_tasks[task_id]) { present_tasks[task_id] = true; filled_tasks = filled_tasks + 1; } else { if (task_id == task_number::A5 || task_id == task_number::B5 || task_id == task_number::C5) { if (!present_tasks[task_id + 1]) { present_tasks[task_id + 1] = true; filled_tasks = filled_tasks + 1; } } } if (filled_tasks == ALL_TASKS_COUNT) { std::cout << "TAK"; return 0; } } std::cout << "NIE"; return 0; } |