#include <iostream> #include <string> using namespace std; int main() { short int n; string s; short int A5 = 0, B5 = 0, C5 = 0; pair<pair<bool, bool>, bool> stuff[4]; for (int a = 0; a < 4; a++) { stuff[a].first.first = 0; stuff[a].first.second = 0; stuff[a].second = 0; } cin >> n; for (int a = 0; a < n; a++) { cin >> s; switch (s[0]) { case '1': if (s[1] == 'A') { stuff[0].first.first = 1; } else { if (s[1] == 'B') { stuff[0].first.second = 1; } else { stuff[0].second = 1; } } break; case '2': if (s[1] == 'A') { stuff[1].first.first = 1; } else { if (s[1] == 'B') { stuff[1].first.second = 1; } else { stuff[1].second = 1; } } break; case '3': if (s[1] == 'A') { stuff[2].first.first = 1; } else { if (s[1] == 'B') { stuff[2].first.second = 1; } else { stuff[2].second = 1; } } break; case '4': if (s[1] == 'A') { stuff[3].first.first = 1; } else { if (s[1] == 'B') { stuff[3].first.second = 1; } else { stuff[3].second = 1; } } break; case '5': if (s[1] == 'A') { A5++; } else { if (s[1] == 'B') { B5++; } else { C5++; } } break; } } bool wynik = 1; if (A5 < 2) { wynik = 0; } else { if (B5 < 2) { wynik = 0; } else { if (C5 < 2) { wynik = 0; } else { for (int a = 0; a < 4; a++) { if (stuff[a].first.first == 0) { wynik = 0; break; } if (stuff[a].first.second == 0) { wynik = 0; break; } if (stuff[a].second == 0) { wynik = 0; break; } } } } } if (wynik==1) { cout << "TAK"; } else { cout << "NIE"; } }
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 | #include <iostream> #include <string> using namespace std; int main() { short int n; string s; short int A5 = 0, B5 = 0, C5 = 0; pair<pair<bool, bool>, bool> stuff[4]; for (int a = 0; a < 4; a++) { stuff[a].first.first = 0; stuff[a].first.second = 0; stuff[a].second = 0; } cin >> n; for (int a = 0; a < n; a++) { cin >> s; switch (s[0]) { case '1': if (s[1] == 'A') { stuff[0].first.first = 1; } else { if (s[1] == 'B') { stuff[0].first.second = 1; } else { stuff[0].second = 1; } } break; case '2': if (s[1] == 'A') { stuff[1].first.first = 1; } else { if (s[1] == 'B') { stuff[1].first.second = 1; } else { stuff[1].second = 1; } } break; case '3': if (s[1] == 'A') { stuff[2].first.first = 1; } else { if (s[1] == 'B') { stuff[2].first.second = 1; } else { stuff[2].second = 1; } } break; case '4': if (s[1] == 'A') { stuff[3].first.first = 1; } else { if (s[1] == 'B') { stuff[3].first.second = 1; } else { stuff[3].second = 1; } } break; case '5': if (s[1] == 'A') { A5++; } else { if (s[1] == 'B') { B5++; } else { C5++; } } break; } } bool wynik = 1; if (A5 < 2) { wynik = 0; } else { if (B5 < 2) { wynik = 0; } else { if (C5 < 2) { wynik = 0; } else { for (int a = 0; a < 4; a++) { if (stuff[a].first.first == 0) { wynik = 0; break; } if (stuff[a].first.second == 0) { wynik = 0; break; } if (stuff[a].second == 0) { wynik = 0; break; } } } } } if (wynik==1) { cout << "TAK"; } else { cout << "NIE"; } } |