#include <iostream> using namespace std; int tabp[26]; int tab2p[26]; int tabnp[26]; int tab2np[26]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { char pom1; cin >> pom1; if (i%2==0) tabp[pom1 - 'a']++; else tabnp[pom1 - 'a']++; } for (int i = 0; i < n; ++i) { char pom1; cin >> pom1; if (i%2==0) tab2p[pom1 - 'a']++; else tab2np[pom1 - 'a']++; } bool tak = true; for (int i = 0; i < 26; ++i) { if (tabp[i] != tab2p[i])tak = false; if (tabnp[i] != tab2np[i])tak = false; } if (tak)cout << "TAK"; else cout << "NIE"; }
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 | #include <iostream> using namespace std; int tabp[26]; int tab2p[26]; int tabnp[26]; int tab2np[26]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { char pom1; cin >> pom1; if (i%2==0) tabp[pom1 - 'a']++; else tabnp[pom1 - 'a']++; } for (int i = 0; i < n; ++i) { char pom1; cin >> pom1; if (i%2==0) tab2p[pom1 - 'a']++; else tab2np[pom1 - 'a']++; } bool tak = true; for (int i = 0; i < 26; ++i) { if (tabp[i] != tab2p[i])tak = false; if (tabnp[i] != tab2np[i])tak = false; } if (tak)cout << "TAK"; else cout << "NIE"; } |