#include <bits/stdc++.h>
using namespace std;
const int N = 112;
int n;
char liczba;
char litera;
bool t[20];
int pieA,pieB,pieC;
bool res = true;
int zmiana (char x){
if (x == 'A'){
return 1;
}
else if (x == 'B'){
return 2;
}
else if (x == 'C'){
return 3;
}
}
int main () {
ios_base::sync_with_stdio(0);
cin >> n ;
for (int i = 1;i <= n;i++){
cin >> liczba >> litera;
if ((int)liczba-'0' <= 4){
t[((int)liczba-48)*3+zmiana(litera)] = true;
}
else{
if (zmiana(litera) == 1){
pieA ++;
}
if (zmiana(litera) == 2){
pieB ++;
}
if (zmiana(litera) == 3){
pieC ++;
}
}
}
for (int i = 4;i <= 15;i++){
if (!t[i]){
res = false;
}
}
if (pieA < 2){
res = false;
}
if (pieB < 2){
res = false;
}
if (pieC < 2){
res = false;
}
if (res){
cout << "TAK" << '\n';
}
else{
cout << "NIE" <<'\n';
}
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 | #include <bits/stdc++.h> using namespace std; const int N = 112; int n; char liczba; char litera; bool t[20]; int pieA,pieB,pieC; bool res = true; int zmiana (char x){ if (x == 'A'){ return 1; } else if (x == 'B'){ return 2; } else if (x == 'C'){ return 3; } } int main () { ios_base::sync_with_stdio(0); cin >> n ; for (int i = 1;i <= n;i++){ cin >> liczba >> litera; if ((int)liczba-'0' <= 4){ t[((int)liczba-48)*3+zmiana(litera)] = true; } else{ if (zmiana(litera) == 1){ pieA ++; } if (zmiana(litera) == 2){ pieB ++; } if (zmiana(litera) == 3){ pieC ++; } } } for (int i = 4;i <= 15;i++){ if (!t[i]){ res = false; } } if (pieA < 2){ res = false; } if (pieB < 2){ res = false; } if (pieC < 2){ res = false; } if (res){ cout << "TAK" << '\n'; } else{ cout << "NIE" <<'\n'; } return 0; } |
English