#include <iostream> using namespace std; int count_letters_0[300]; int count_letters_1[300]; void calculate_count(const string& s1, const string& s2, int n) { for (int i = 0; i < n; i++) { if (i % 2 == 0) { count_letters_0[s1[i]]++; count_letters_0[s2[i]]--; } else { count_letters_1[s1[i]]++; count_letters_1[s2[i]]--; } } } bool check_count() { for (int i = 'a'; i <= 'z'; i++) { if (count_letters_0[i] != 0 || count_letters_1[i] != 0) { return false; } } return true; } int main() { int n; cin >> n; string s1, s2; cin >> s1; cin >> s2; calculate_count(s1, s2, n); if (check_count()) { 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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include <iostream> using namespace std; int count_letters_0[300]; int count_letters_1[300]; void calculate_count(const string& s1, const string& s2, int n) { for (int i = 0; i < n; i++) { if (i % 2 == 0) { count_letters_0[s1[i]]++; count_letters_0[s2[i]]--; } else { count_letters_1[s1[i]]++; count_letters_1[s2[i]]--; } } } bool check_count() { for (int i = 'a'; i <= 'z'; i++) { if (count_letters_0[i] != 0 || count_letters_1[i] != 0) { return false; } } return true; } int main() { int n; cin >> n; string s1, s2; cin >> s1; cin >> s2; calculate_count(s1, s2, n); if (check_count()) { cout << "TAK"; } else { cout << "NIE"; } return 0; } |