#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); int n; std::cin >> n; std::string src, dst; std::cin >> src >> dst; std::unordered_map<std::string::value_type, std::pair<int,int>> hs, hd; for(int i=0;i<26;i++) { hs['a'+i] = std::make_pair<int,int>(0,0); hd['a'+i] = std::make_pair<int,int>(0,0); } for(int i=0; i<n; i++) { if(i%2==0) { hs[src[i]].first++; hd[dst[i]].first++; } else { hs[src[i]].second++; hd[dst[i]].second++; } } std::cout << (hs == hd ? "TAK\n" : "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 30 31 32 33 34 35 36 37 38 39 40 | #include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); int n; std::cin >> n; std::string src, dst; std::cin >> src >> dst; std::unordered_map<std::string::value_type, std::pair<int,int>> hs, hd; for(int i=0;i<26;i++) { hs['a'+i] = std::make_pair<int,int>(0,0); hd['a'+i] = std::make_pair<int,int>(0,0); } for(int i=0; i<n; i++) { if(i%2==0) { hs[src[i]].first++; hd[dst[i]].first++; } else { hs[src[i]].second++; hd[dst[i]].second++; } } std::cout << (hs == hd ? "TAK\n" : "NIE\n"); return 0; } |