#include <iostream>
#include <unordered_map>
#include <sstream>
using namespace std;
template <typename T>
void println(T t)
{
cout << t << endl;
}
int main() {
string data_len;
getline(cin, data_len);
string x;
getline(cin, x);
string y;
getline(cin, y);
unordered_map<char, int> x_map;
unordered_map<char, int> y_map;
for (int i = 0; i < y.size(); ++i) {
auto x_ch = x[i];
auto y_ch = y[i];
if (x_map.count(x_ch) > 0){
x_map[x_ch] += 1;
}
else {
x_map[x_ch] = 1;
}
if (y_map.count(y_ch) > 0){
y_map[y_ch] += 1;
}
else {
y_map[y_ch] = 1;
}
}
bool result = true;
for (const auto& mapper: y_map) {
auto key = mapper.first;
auto value = mapper.second;
if (x_map.count(key) == 0){
result = false;
break;
}
if (value != x_map[key]) {
result = false;
break;
}
}
if (result){
println("TAK");
}
else{
println("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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #include <iostream> #include <unordered_map> #include <sstream> using namespace std; template <typename T> void println(T t) { cout << t << endl; } int main() { string data_len; getline(cin, data_len); string x; getline(cin, x); string y; getline(cin, y); unordered_map<char, int> x_map; unordered_map<char, int> y_map; for (int i = 0; i < y.size(); ++i) { auto x_ch = x[i]; auto y_ch = y[i]; if (x_map.count(x_ch) > 0){ x_map[x_ch] += 1; } else { x_map[x_ch] = 1; } if (y_map.count(y_ch) > 0){ y_map[y_ch] += 1; } else { y_map[y_ch] = 1; } } bool result = true; for (const auto& mapper: y_map) { auto key = mapper.first; auto value = mapper.second; if (x_map.count(key) == 0){ result = false; break; } if (value != x_map[key]) { result = false; break; } } if (result){ println("TAK"); } else{ println("NIE"); } } |
English