#include<iostream> #include<string> using namespace std; int zadania[5][3]; int main() { int n; cin >> n; string words[n]; bool check = true; for(int i = 0; i < n; i++) cin >> words[i]; for(int i = 0; i < n; i++) { int a = (int)words[i][0] - 48; int b; if(words[i][1] == 'A') b = 0; else if (words[i][1] == 'B') b = 1; else b = 2; zadania[a-1][b] += 1; } for(int i = 0; i < 4; i++) { for(int j = 0; j < 3; j++) if(zadania[i][j] < 1) { check = false; j = 10; i = 10; } } if(check) { for(int j = 0; j < 3; j++) { if(zadania[4][j] < 2) { check = false; j = 10; } } } if(check) 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 | #include<iostream> #include<string> using namespace std; int zadania[5][3]; int main() { int n; cin >> n; string words[n]; bool check = true; for(int i = 0; i < n; i++) cin >> words[i]; for(int i = 0; i < n; i++) { int a = (int)words[i][0] - 48; int b; if(words[i][1] == 'A') b = 0; else if (words[i][1] == 'B') b = 1; else b = 2; zadania[a-1][b] += 1; } for(int i = 0; i < 4; i++) { for(int j = 0; j < 3; j++) if(zadania[i][j] < 1) { check = false; j = 10; i = 10; } } if(check) { for(int j = 0; j < 3; j++) { if(zadania[4][j] < 2) { check = false; j = 10; } } } if(check) cout << "TAK"; else cout << "NIE"; } |