#include <cstdio>
#include <map>
#include <string>
const int asc1=49;
const int asc2=65;
using namespace std;
map<string,int> buckets;
int main()
{
int n;
scanf("%d",&n);
if(n < 18) { printf("NIE\n"); return 0; }
string s(2,' '),s1,s2;
for(int i=0; i<5; ++i)
for(int j=0; j<3; ++j) {
s1=asc1+i;
s2=asc2+j;
s1+=s2;
buckets[s1]=0;
}
for(int i=0; i<n; ++i) {
scanf("%2s",&s[0]);
buckets[s]++;
}
bool ok=true;
int i;
for( i=0; i<4; ++i)
for(int j=0; j<3; ++j) {
s1=asc1+i;
s2=asc2+j;
s1+=s2;
if(buckets[s1] < 1) ok=false;
}
for(int j=0; j<3; ++j) {
s1=asc1+i;
s2=asc2+j;
s1+=s2;
if(buckets[s1] < 2 ) ok=false;
}
if(ok) printf("TAK\n");
else printf("NIE\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 49 50 51 | #include <cstdio> #include <map> #include <string> const int asc1=49; const int asc2=65; using namespace std; map<string,int> buckets; int main() { int n; scanf("%d",&n); if(n < 18) { printf("NIE\n"); return 0; } string s(2,' '),s1,s2; for(int i=0; i<5; ++i) for(int j=0; j<3; ++j) { s1=asc1+i; s2=asc2+j; s1+=s2; buckets[s1]=0; } for(int i=0; i<n; ++i) { scanf("%2s",&s[0]); buckets[s]++; } bool ok=true; int i; for( i=0; i<4; ++i) for(int j=0; j<3; ++j) { s1=asc1+i; s2=asc2+j; s1+=s2; if(buckets[s1] < 1) ok=false; } for(int j=0; j<3; ++j) { s1=asc1+i; s2=asc2+j; s1+=s2; if(buckets[s1] < 2 ) ok=false; } if(ok) printf("TAK\n"); else printf("NIE\n"); return 0; } |
English