#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,A[6]={},B[6]={},C[6]={};
string a;
cin>>n;
while(n--)
{
cin>>a;
int licz=(int)a[0]-48;
if(a[1]=='A')
A[licz]++;
else if (a[1]=='B')
B[licz]++;
else if (a[1]=='C')
C[licz]++;
}
bool ok=0;
for(int i=1;i<=5;i++)
{
if((A[i]>0 && B[i]>0 && C[i]>0 && i<5) || (i==5 && A[i]>1 && B[i]>1 && C[i]>1))
ok=1;
else
{
ok=0;
break;
}
}
if(ok?cout<<"TAK":cout<<"NIE");
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 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,A[6]={},B[6]={},C[6]={}; string a; cin>>n; while(n--) { cin>>a; int licz=(int)a[0]-48; if(a[1]=='A') A[licz]++; else if (a[1]=='B') B[licz]++; else if (a[1]=='C') C[licz]++; } bool ok=0; for(int i=1;i<=5;i++) { if((A[i]>0 && B[i]>0 && C[i]>0 && i<5) || (i==5 && A[i]>1 && B[i]>1 && C[i]>1)) ok=1; else { ok=0; break; } } if(ok?cout<<"TAK":cout<<"NIE"); return 0; } |
English