#include<iostream>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
int n, tab[4][6]={0}, tst;
char y, x;
cin >> n;
for (int i=1; i<=n;i++)
{
cin >> x >> y;
tab[y-64][x-48]++;
}
for (int i=1;i<4;i++)
{
tst=1;
for (int j=1;j<5;j++)
tst*=tab[i][j];
if(tst>=1 && tab[i][5]>=2) tab[i][0]=1;
}
tst=1;
for (int i=1;i<4;i++)
tst*=tab[i][0];
if (tst == 1) cout << "TAK";
else 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 | #include<iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); int n, tab[4][6]={0}, tst; char y, x; cin >> n; for (int i=1; i<=n;i++) { cin >> x >> y; tab[y-64][x-48]++; } for (int i=1;i<4;i++) { tst=1; for (int j=1;j<5;j++) tst*=tab[i][j]; if(tst>=1 && tab[i][5]>=2) tab[i][0]=1; } tst=1; for (int i=1;i<4;i++) tst*=tab[i][0]; if (tst == 1) cout << "TAK"; else cout << "NIE"; return 0; } |
English