#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include<cmath>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
#define gc getchar
#define pc putchar
int main()
{
int n;
cin>>n;
int idx[] ={11,12,13,21,22,23,31,32,33,41,42,43,51,52,53};//15
int tab[100];
for(int j =0; j<12;j++){
tab[idx[j]]=1;
}
tab[idx[12]]=tab[idx[13]]=tab[idx[14]]=2;
for(int i=0; i<n;i++){
char b[3];
cin>>b;
//cout<<b<<endl;
int x = (b[0]-'0')*10;
if(b[1]=='A'){
x+=1;
}
if(b[1]=='B'){
x+=2;
}
if(b[1]=='C'){
x+=3;
}
tab[x]--;
}
for(int j =0; j<15;j++){
if( tab[idx[j]] >0){
cout<<"NIE\n";
return 0;
}
}
cout<<"TAK\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 | #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string> #include<cmath> #include <math.h> #include <bits/stdc++.h> using namespace std; #define gc getchar #define pc putchar int main() { int n; cin>>n; int idx[] ={11,12,13,21,22,23,31,32,33,41,42,43,51,52,53};//15 int tab[100]; for(int j =0; j<12;j++){ tab[idx[j]]=1; } tab[idx[12]]=tab[idx[13]]=tab[idx[14]]=2; for(int i=0; i<n;i++){ char b[3]; cin>>b; //cout<<b<<endl; int x = (b[0]-'0')*10; if(b[1]=='A'){ x+=1; } if(b[1]=='B'){ x+=2; } if(b[1]=='C'){ x+=3; } tab[x]--; } for(int j =0; j<15;j++){ if( tab[idx[j]] >0){ cout<<"NIE\n"; return 0; } } cout<<"TAK\n"; return 0; } |
English