#include <iostream> #include <string> #include <set> using namespace std; int main() { int n; cin >> n; string s1, s2; cin >> s1 >> s2; multiset<int> odd1; multiset<int> odd2; multiset<int> even1; multiset<int> even2; for (int i = 0; i < s1.size(); i += 2) { even1.insert(s1[i]); even2.insert(s2[i]); } for (int i = 1; i < s1.size(); i += 2) { odd1.insert(s1[i]); odd2.insert(s2[i]); } if (odd1 == odd2 && even1 == even2) cout << "TAK"; else cout << "NIE"; 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 | #include <iostream> #include <string> #include <set> using namespace std; int main() { int n; cin >> n; string s1, s2; cin >> s1 >> s2; multiset<int> odd1; multiset<int> odd2; multiset<int> even1; multiset<int> even2; for (int i = 0; i < s1.size(); i += 2) { even1.insert(s1[i]); even2.insert(s2[i]); } for (int i = 1; i < s1.size(); i += 2) { odd1.insert(s1[i]); odd2.insert(s2[i]); } if (odd1 == odd2 && even1 == even2) cout << "TAK"; else cout << "NIE"; return 0; } |