#include <stdio.h> #include <iostream> using namespace std; int main() { int n_max = 300000; int n; scanf("%d", &n); int * toys1_even = new int[n_max]; int * toys1_odd = new int[n_max]; int * toys2_even = new int[n_max]; int * toys2_odd = new int[n_max]; char tab[n_max]; scanf("%s", tab); char letter; for (int i = 0; i < n; i++) { letter = tab[i]; if (i % 2 == 0) { toys1_even[letter - 'a'] += 1; } else { toys1_odd[letter - 'a'] += 1; } } scanf("%s", tab); for (int i = 0; i < n; i++) { letter = tab[i]; if (i % 2 == 0) { toys2_even[letter - 'a'] += 1; } else { toys2_odd[letter - 'a'] += 1; } } bool match = true; for (int i = 0; i < 26; i++) { if ((toys1_odd[i] != toys2_odd[i]) || (toys1_even[i] != toys2_even[i])) { match = false; } } if (match) { printf("TAK\n"); } else { printf("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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #include <stdio.h> #include <iostream> using namespace std; int main() { int n_max = 300000; int n; scanf("%d", &n); int * toys1_even = new int[n_max]; int * toys1_odd = new int[n_max]; int * toys2_even = new int[n_max]; int * toys2_odd = new int[n_max]; char tab[n_max]; scanf("%s", tab); char letter; for (int i = 0; i < n; i++) { letter = tab[i]; if (i % 2 == 0) { toys1_even[letter - 'a'] += 1; } else { toys1_odd[letter - 'a'] += 1; } } scanf("%s", tab); for (int i = 0; i < n; i++) { letter = tab[i]; if (i % 2 == 0) { toys2_even[letter - 'a'] += 1; } else { toys2_odd[letter - 'a'] += 1; } } bool match = true; for (int i = 0; i < 26; i++) { if ((toys1_odd[i] != toys2_odd[i]) || (toys1_even[i] != toys2_even[i])) { match = false; } } if (match) { printf("TAK\n"); } else { printf("NIE\n"); } return 0; } |