#include <iostream> #include <string> #include <cstring> std::string split(std::string line, int word_index, char split = ' ') { if(line.length() < 3 || word_index > line.length()) { return "-1"; } int c = 0; std::string to_return = ""; for (int i = 0; i < line.length(); i++) { if (line[i] == split && c != word_index) { c++; } else if (line[i] == split && c == word_index) { return to_return; } else if(c == word_index) { to_return += line[i]; } } return to_return; } int main() { std::string line; getline(std::cin, line); int licz_pomyslow = stoi(line); int c = 0; int pomysly[5][3] = {0}; getline(std::cin, line); for (int i = 0; i < licz_pomyslow; i++) { int number = split(line, i)[0] - 49; int letter = split(line, i)[1] - 65; if (number == 4) { if (pomysly[number][letter] < 2) { pomysly[number][letter]++; c++; } } else { if (pomysly[number][letter] < 1) { pomysly[number][letter]++; c++; } } if(c >= 18) { 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 | #include <iostream> #include <string> #include <cstring> std::string split(std::string line, int word_index, char split = ' ') { if(line.length() < 3 || word_index > line.length()) { return "-1"; } int c = 0; std::string to_return = ""; for (int i = 0; i < line.length(); i++) { if (line[i] == split && c != word_index) { c++; } else if (line[i] == split && c == word_index) { return to_return; } else if(c == word_index) { to_return += line[i]; } } return to_return; } int main() { std::string line; getline(std::cin, line); int licz_pomyslow = stoi(line); int c = 0; int pomysly[5][3] = {0}; getline(std::cin, line); for (int i = 0; i < licz_pomyslow; i++) { int number = split(line, i)[0] - 49; int letter = split(line, i)[1] - 65; if (number == 4) { if (pomysly[number][letter] < 2) { pomysly[number][letter]++; c++; } } else { if (pomysly[number][letter] < 1) { pomysly[number][letter]++; c++; } } if(c >= 18) { std::cout << "TAK"; return 0; } } std::cout << "NIE"; return 0; } |