#include <iostream> using namespace std; int tab[6][3]; int n,m,k; char l; string a; bool zle; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; for(int i = 0; i < n; i++) { cin>>a; k = a[0] - '0'; l = a[1]; if( l == 'A') m = 0; if( l == 'B') m = 1; if( l == 'C') m = 2; tab[k][m]++; //cout<<k<<l<<m<<' '<<tab[k][m]<<endl; } for(int i = 1; i < 6; i++) { for(int j = 0; j < 3; j++) { //cout<<tab[i][j]<<' '<<i<<' '<<j<<endl; if(tab[i][j] == 0) { zle = true; break; } if(i == 5 && tab[i][j] < 2) { zle = true; break; } } } if( zle == true) cout<<"NIE"; else cout<<"TAK"; }
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> using namespace std; int tab[6][3]; int n,m,k; char l; string a; bool zle; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; for(int i = 0; i < n; i++) { cin>>a; k = a[0] - '0'; l = a[1]; if( l == 'A') m = 0; if( l == 'B') m = 1; if( l == 'C') m = 2; tab[k][m]++; //cout<<k<<l<<m<<' '<<tab[k][m]<<endl; } for(int i = 1; i < 6; i++) { for(int j = 0; j < 3; j++) { //cout<<tab[i][j]<<' '<<i<<' '<<j<<endl; if(tab[i][j] == 0) { zle = true; break; } if(i == 5 && tab[i][j] < 2) { zle = true; break; } } } if( zle == true) cout<<"NIE"; else cout<<"TAK"; } |