#include <iostream> using namespace std; #define CNUM 26 int chrs[2][2][CNUM]; int main() { int i, j, n; unsigned char c; bool ok = true; ios_base::sync_with_stdio(0); cin >> n; for (i = 0; i < CNUM; ++i) { chrs[0][0][i] = 0; chrs[0][1][i] = 0; chrs[1][0][i] = 0; chrs[1][1][i] = 0; } for (j = 0; j < 2; ++j) { for (i = 0; i < n; ++i) { cin >> c; c -= 'a'; chrs[j][i % 2][c] += 1; } } for (c = 0; ok && c < CNUM; ++c) { ok = (chrs[0][0][c] == chrs[1][0][c]) && (chrs[0][1][c] == chrs[1][1][c]); } cout << (ok ? "TAK" : "NIE") << endl; 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 | #include <iostream> using namespace std; #define CNUM 26 int chrs[2][2][CNUM]; int main() { int i, j, n; unsigned char c; bool ok = true; ios_base::sync_with_stdio(0); cin >> n; for (i = 0; i < CNUM; ++i) { chrs[0][0][i] = 0; chrs[0][1][i] = 0; chrs[1][0][i] = 0; chrs[1][1][i] = 0; } for (j = 0; j < 2; ++j) { for (i = 0; i < n; ++i) { cin >> c; c -= 'a'; chrs[j][i % 2][c] += 1; } } for (c = 0; ok && c < CNUM; ++c) { ok = (chrs[0][0][c] == chrs[1][0][c]) && (chrs[0][1][c] == chrs[1][1][c]); } cout << (ok ? "TAK" : "NIE") << endl; return 0; } |