#include <bits/stdc++.h> using namespace std; #define show if(0) int n=0,x=1,a=0,buf,mid,l; bool error=0; int first[26]{0},second[26]{0}; int main(){ cin>>l; if(l>0&&l<3999990){ string s; cin>>s; for(int i=0;i<l/2+1;i++){ if(s[i]!=s[l-1-i]) error=1; } } else{ do{ x=getchar()-97; if(x==-87) a++; if(x!=-87&&a>0){ n++; show cout<<x<<endl; if(n==1) mid=x; else{ if(n==2){ first[mid]++; mid=x; second[x]++; } else{ if(n%2==1){ second[mid]--; second[x]++; buf=x; } else{ first[mid]++; second[x]++; mid=buf; } } } show{ for(int i=0;i<26;i++){ cout<<i<<" f "<<first[i]<<endl; cout<<i<<" s "<<second[i]<<endl; } cout<<endl; } } }while(x!=-87||a<2); show{ cout<<"dlugosc: "<<n<<endl; for(int i=0;i<26;i++){ cout<<i<<" f "<<first[i]<<endl; cout<<i<<" s "<<second[i]<<endl; } cout<<endl; } for(int i=0;i<26;i++){ if(first[i]!=second[i]){ error=1; } } } if(error) cout<<"NIE"<<endl; else cout<<"TAK"<<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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #include <bits/stdc++.h> using namespace std; #define show if(0) int n=0,x=1,a=0,buf,mid,l; bool error=0; int first[26]{0},second[26]{0}; int main(){ cin>>l; if(l>0&&l<3999990){ string s; cin>>s; for(int i=0;i<l/2+1;i++){ if(s[i]!=s[l-1-i]) error=1; } } else{ do{ x=getchar()-97; if(x==-87) a++; if(x!=-87&&a>0){ n++; show cout<<x<<endl; if(n==1) mid=x; else{ if(n==2){ first[mid]++; mid=x; second[x]++; } else{ if(n%2==1){ second[mid]--; second[x]++; buf=x; } else{ first[mid]++; second[x]++; mid=buf; } } } show{ for(int i=0;i<26;i++){ cout<<i<<" f "<<first[i]<<endl; cout<<i<<" s "<<second[i]<<endl; } cout<<endl; } } }while(x!=-87||a<2); show{ cout<<"dlugosc: "<<n<<endl; for(int i=0;i<26;i++){ cout<<i<<" f "<<first[i]<<endl; cout<<i<<" s "<<second[i]<<endl; } cout<<endl; } for(int i=0;i<26;i++){ if(first[i]!=second[i]){ error=1; } } } if(error) cout<<"NIE"<<endl; else cout<<"TAK"<<endl; return 0; } |