#include <iostream>
#include <string>
using namespace std;
int N;
string str;
int poma=0, pomb=0, pomc=0, i;
bool tab[15];
bool spr ()
{
for (i=0; i<N; i++)
{
cin>>str;
if (str[0]=='1')
{
if (str[1]=='A')
tab[0]=true;
if (str[1]=='B')
tab[1]=true;
if (str[1]=='C')
tab[2]=true;
}
if (str[0]=='2')
{
if (str[1]=='A')
tab[3]=true;
if (str[1]=='B')
tab[4]=true;
if (str[1]=='C')
tab[5]=true;
}
if (str[0]=='3')
{
if (str[1]=='A')
tab[6]=true;
if (str[1]=='B')
tab[7]=true;
if (str[1]=='C')
tab[8]=true;
}
if (str[0]=='4')
{
if (str[1]=='A')
tab[9]=true;
if (str[1]=='B')
tab[10]=true;
if (str[1]=='C')
tab[11]=true;
}
if (str[0]=='5')
{
if (str[1]=='A')
poma++;
if (str[1]=='B')
pomb++;
if (str[1]=='C')
pomc++;
}
}
if (poma>=2)
tab[12]=true;
if (pomb>=2)
tab[13]=true;
if (pomc>=2)
tab[14]=true;
for (i=0; i<15; i++)
{
if (tab[i]==false)
{
return false;
}
}
return true;
}
int main()
{
cin>>N;
for (i=0; i<15; i++)
{
tab[i]=false;
}
if (spr()==false)
cout<<"NIE"<<endl;
else
cout<<"TAK"<<endl;
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #include <iostream> #include <string> using namespace std; int N; string str; int poma=0, pomb=0, pomc=0, i; bool tab[15]; bool spr () { for (i=0; i<N; i++) { cin>>str; if (str[0]=='1') { if (str[1]=='A') tab[0]=true; if (str[1]=='B') tab[1]=true; if (str[1]=='C') tab[2]=true; } if (str[0]=='2') { if (str[1]=='A') tab[3]=true; if (str[1]=='B') tab[4]=true; if (str[1]=='C') tab[5]=true; } if (str[0]=='3') { if (str[1]=='A') tab[6]=true; if (str[1]=='B') tab[7]=true; if (str[1]=='C') tab[8]=true; } if (str[0]=='4') { if (str[1]=='A') tab[9]=true; if (str[1]=='B') tab[10]=true; if (str[1]=='C') tab[11]=true; } if (str[0]=='5') { if (str[1]=='A') poma++; if (str[1]=='B') pomb++; if (str[1]=='C') pomc++; } } if (poma>=2) tab[12]=true; if (pomb>=2) tab[13]=true; if (pomc>=2) tab[14]=true; for (i=0; i<15; i++) { if (tab[i]==false) { return false; } } return true; } int main() { cin>>N; for (i=0; i<15; i++) { tab[i]=false; } if (spr()==false) cout<<"NIE"<<endl; else cout<<"TAK"<<endl; return 0; } |
English