#include <iostream> using namespace std; string s; int d; int main() { cin>>d; if(d==0) { cin>>s; int a=s.length(); if(a%2==1){ a=a/2+1; for(int i=a-2;i>=0;i--) { if(s[i]!=s[a]) {cout<<"NIE"; return 0;} a++; } cout<<"TAK"; return 0; } a=a/2; for(int i=a-1;i>=0;i--) { if(s[i]!=s[a]) {cout<<"NIE"; return 0;} a++; } cout<<"TAK"; } else { cin>>s; if(d%2==1){ d=d/2+1; for(int i=d-2;i>=0;i--) { if(s[i]!=s[d]) {cout<<"NIE"; return 0;} d++; } cout<<"TAK"; return 0; } d=d/2; for(int i=d-1;i>=0;i--) { if(s[i]!=s[d]) {cout<<"NIE"; return 0;} d++; } cout<<"TAK"; } 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 | #include <iostream> using namespace std; string s; int d; int main() { cin>>d; if(d==0) { cin>>s; int a=s.length(); if(a%2==1){ a=a/2+1; for(int i=a-2;i>=0;i--) { if(s[i]!=s[a]) {cout<<"NIE"; return 0;} a++; } cout<<"TAK"; return 0; } a=a/2; for(int i=a-1;i>=0;i--) { if(s[i]!=s[a]) {cout<<"NIE"; return 0;} a++; } cout<<"TAK"; } else { cin>>s; if(d%2==1){ d=d/2+1; for(int i=d-2;i>=0;i--) { if(s[i]!=s[d]) {cout<<"NIE"; return 0;} d++; } cout<<"TAK"; return 0; } d=d/2; for(int i=d-1;i>=0;i--) { if(s[i]!=s[d]) {cout<<"NIE"; return 0;} d++; } cout<<"TAK"; } return 0;} |