#include <iostream> #include <fstream> #include <map> #include <string> using namespace std; #ifdef USE_CERR_LOG #define LOG if (true) cerr const bool LogEnabled = true; #else #define LOG if (false) cerr const bool LogEnabled = false; #endif bool LogBigEnabled = true; #ifdef USE_FILE_CIN ifstream fin("zab0.in"); #define cin fin #endif int main() { int n; string srcToys, destToys; map<pair<char, int>, int> toyCount; cin >> n >> srcToys >> destToys; bool ok = true; for (int i = 0; i < n; i++) { char toy = destToys[i]; toyCount[make_pair(toy, i&1)] ++; } for (int i = 0; i < n; i++) { char toy = srcToys[i]; auto toyAndPos = make_pair(toy, i&1); if (toyCount[toyAndPos] > 0) { toyCount[toyAndPos] --; } else { ok = false; break; } } cout << (ok ? "TAK" : "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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #include <iostream> #include <fstream> #include <map> #include <string> using namespace std; #ifdef USE_CERR_LOG #define LOG if (true) cerr const bool LogEnabled = true; #else #define LOG if (false) cerr const bool LogEnabled = false; #endif bool LogBigEnabled = true; #ifdef USE_FILE_CIN ifstream fin("zab0.in"); #define cin fin #endif int main() { int n; string srcToys, destToys; map<pair<char, int>, int> toyCount; cin >> n >> srcToys >> destToys; bool ok = true; for (int i = 0; i < n; i++) { char toy = destToys[i]; toyCount[make_pair(toy, i&1)] ++; } for (int i = 0; i < n; i++) { char toy = srcToys[i]; auto toyAndPos = make_pair(toy, i&1); if (toyCount[toyAndPos] > 0) { toyCount[toyAndPos] --; } else { ok = false; break; } } cout << (ok ? "TAK" : "NIE"); return 0; } |