#include<iostream> using namespace std; int main(){ int p1[26]={0},p2[26]={0},np1[26]={0},np2[26]={0},n; string s1,s2; cin>>n; cin>>s1>>s2; for(int i=0;i<n;i+=2){ np1[(int)s1[i]-97]++; np2[(int)s2[i]-97]++; } for(int i=1;i<n;i+=2){ p1[(int)s1[i]-97]++; p2[(int)s2[i]-97]++; } for(int i=0;i<26;i++){ if(p1[i]!=p2[i] || np1[i]!=np2[i]){ cout<<"NIE"; return 0; } } 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 | #include<iostream> using namespace std; int main(){ int p1[26]={0},p2[26]={0},np1[26]={0},np2[26]={0},n; string s1,s2; cin>>n; cin>>s1>>s2; for(int i=0;i<n;i+=2){ np1[(int)s1[i]-97]++; np2[(int)s2[i]-97]++; } for(int i=1;i<n;i+=2){ p1[(int)s1[i]-97]++; p2[(int)s2[i]-97]++; } for(int i=0;i<26;i++){ if(p1[i]!=p2[i] || np1[i]!=np2[i]){ cout<<"NIE"; return 0; } } cout<<"TAK"; return 0; } |