#include <iostream>
int main()
{
std::ios::sync_with_stdio(false);
int a[6], b[6], c[6];
std::fill_n(a, 6, 0);
std::fill_n(b, 6, 0);
std::fill_n(c, 6, 0);
int n;
std::cin >> n;
for(int i=1; i<=n; i++)
{
std::string w;
std::cin >> w;
if(w.length()<2)
{
std::cout << "NIE";
return 0;
}
int round = w[0] - '0';
char group = w[1];
if(round<1 || round>5 || (group!='A' && group!='B' && group!='C'))
{
std::cout << "NIE";
return 0;
}
if(group=='A') a[round]++;
if(group=='B') b[round]++;
if(group=='C') c[round]++;
}
bool res = true;
for(int i=1; i<=4; i++) if(a[i]<1 || b[i]<1 || c[i]<1) res=false;
if(a[5]<2 || b[5]<2 || c[5]<2) res=false;
std::cout << (res ? "TAK" : "NIE") << std::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 | #include <iostream> int main() { std::ios::sync_with_stdio(false); int a[6], b[6], c[6]; std::fill_n(a, 6, 0); std::fill_n(b, 6, 0); std::fill_n(c, 6, 0); int n; std::cin >> n; for(int i=1; i<=n; i++) { std::string w; std::cin >> w; if(w.length()<2) { std::cout << "NIE"; return 0; } int round = w[0] - '0'; char group = w[1]; if(round<1 || round>5 || (group!='A' && group!='B' && group!='C')) { std::cout << "NIE"; return 0; } if(group=='A') a[round]++; if(group=='B') b[round]++; if(group=='C') c[round]++; } bool res = true; for(int i=1; i<=4; i++) if(a[i]<1 || b[i]<1 || c[i]<1) res=false; if(a[5]<2 || b[5]<2 || c[5]<2) res=false; std::cout << (res ? "TAK" : "NIE") << std::endl; return 0; } |
English