#include <iostream> #include <stdio.h> using namespace std; #include <cstdio> int getNumber() { int number = 0; int letter; do { letter = getchar(); } while (letter <= 32); number = letter - '0'; while (true) { letter = getchar(); if (letter <= 32) { break; } number = number * 10 + (letter - '0'); } return number; } int main() { int n; n = getNumber(); // person / toy / position parity int count[2][26][2]; for (int person = 0; person < 2; person++) { for (int toy = 0; toy < 26; toy++) { for (int position = 0; position < 2; position++) { count[person][toy][position] = 0; } } } int letter; for (int person = 0; person < 2; person++) { for (int position = 0; position < n; position++) { do { letter = getchar(); } while (letter <= 32); count[person][letter - 'a'][position % 2]++; } } for (int toy = 0; toy < 26; toy++) { for (int position = 0; position < 2; position++) { if (count[0][toy][position] != count[1][toy][position]) { printf("NIE"); return 0; } } } printf("TAK"); 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 56 57 58 59 | #include <iostream> #include <stdio.h> using namespace std; #include <cstdio> int getNumber() { int number = 0; int letter; do { letter = getchar(); } while (letter <= 32); number = letter - '0'; while (true) { letter = getchar(); if (letter <= 32) { break; } number = number * 10 + (letter - '0'); } return number; } int main() { int n; n = getNumber(); // person / toy / position parity int count[2][26][2]; for (int person = 0; person < 2; person++) { for (int toy = 0; toy < 26; toy++) { for (int position = 0; position < 2; position++) { count[person][toy][position] = 0; } } } int letter; for (int person = 0; person < 2; person++) { for (int position = 0; position < n; position++) { do { letter = getchar(); } while (letter <= 32); count[person][letter - 'a'][position % 2]++; } } for (int toy = 0; toy < 26; toy++) { for (int position = 0; position < 2; position++) { if (count[0][toy][position] != count[1][toy][position]) { printf("NIE"); return 0; } } } printf("TAK"); return 0; } |