#include <iostream>
#include <vector>
int main()
{
size_t n;
std::cin >> n;
std::vector<std::pair<int, int>> positions;
for (size_t i = 0u; i < n; i++)
{
char pos[4];
std::cin >> pos;
positions.push_back(std::pair<int, int>(pos[0] - '1', pos[1] - 'A'));
}
char problem_set[5][3];
for (char i = 0; i < 5; i++)
for (char j = 0; j < 3; j++)
problem_set[i][j] = 0;
for (auto& p : positions)
{
problem_set[p.first][p.second]++;
}
for (char i = 0; i < 4; i++)
{
for (char j = 0; j < 3; j++)
{
if (problem_set[i][j] == 0)
{
std::cout << "NIE";
return 0;
}
}
}
for (char j = 0; j < 3; j++)
{
if (problem_set[4][j] < 2)
{
std::cout << "NIE";
return 0;
}
}
std::cout << "TAK";
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 | #include <iostream> #include <vector> int main() { size_t n; std::cin >> n; std::vector<std::pair<int, int>> positions; for (size_t i = 0u; i < n; i++) { char pos[4]; std::cin >> pos; positions.push_back(std::pair<int, int>(pos[0] - '1', pos[1] - 'A')); } char problem_set[5][3]; for (char i = 0; i < 5; i++) for (char j = 0; j < 3; j++) problem_set[i][j] = 0; for (auto& p : positions) { problem_set[p.first][p.second]++; } for (char i = 0; i < 4; i++) { for (char j = 0; j < 3; j++) { if (problem_set[i][j] == 0) { std::cout << "NIE"; return 0; } } } for (char j = 0; j < 3; j++) { if (problem_set[4][j] < 2) { std::cout << "NIE"; return 0; } } std::cout << "TAK"; return 0; } |
English