#include <iostream> #include <string> using namespace std; int tab[2][26]; int main(int argc, char* argv[]) { ios_base::sync_with_stdio (false); string a,b; int i, n; cin >> n; cin >> a; cin >> b; for (i=0; i<n; ++i) { tab[i&1][a[i]-'a']++; tab[i&1][b[i]-'a']--; } for (i=0; i<26; ++i) if(tab[0][i]!=0 || tab[1][i]!=0) goto err; cout << "TAK\n"; return 0; err: cout << "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 | #include <iostream> #include <string> using namespace std; int tab[2][26]; int main(int argc, char* argv[]) { ios_base::sync_with_stdio (false); string a,b; int i, n; cin >> n; cin >> a; cin >> b; for (i=0; i<n; ++i) { tab[i&1][a[i]-'a']++; tab[i&1][b[i]-'a']--; } for (i=0; i<26; ++i) if(tab[0][i]!=0 || tab[1][i]!=0) goto err; cout << "TAK\n"; return 0; err: cout << "NIE\n"; return 0; } |