#include <iostream> #include <string> using namespace std; string a, b; int taba[28]; pair<int,int> tabb[28]; int main() { int n; cin>>n; cin>>a>>b; if (a.size()!=b.size()) { cout<<"NIE\n"; return 0; } for (int i=0; i<n; i++) { taba[a[i]-'a']++; taba[b[i]-'a']-=1; if (i%2==0) { tabb[a[i]-'a'].first++; tabb[b[i]-'a'].first-=1; } if (i%2==1) { tabb[a[i]-'a'].second++; tabb[b[i]-'a'].second-=1; } } for (int i=0; i<27; i++) { if (taba[i]!=0 || tabb[i].first!=0 || tabb[i].second!=0) { cout<<"NIE\n"; return 0; } } cout<<"TAK\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 | #include <iostream> #include <string> using namespace std; string a, b; int taba[28]; pair<int,int> tabb[28]; int main() { int n; cin>>n; cin>>a>>b; if (a.size()!=b.size()) { cout<<"NIE\n"; return 0; } for (int i=0; i<n; i++) { taba[a[i]-'a']++; taba[b[i]-'a']-=1; if (i%2==0) { tabb[a[i]-'a'].first++; tabb[b[i]-'a'].first-=1; } if (i%2==1) { tabb[a[i]-'a'].second++; tabb[b[i]-'a'].second-=1; } } for (int i=0; i<27; i++) { if (taba[i]!=0 || tabb[i].first!=0 || tabb[i].second!=0) { cout<<"NIE\n"; return 0; } } cout<<"TAK\n"; return 0; } |