#include <iostream> #include <vector> using namespace std; int n, A[2][30], B[2][30]; int main() { ios_base::sync_with_stdio(0); cin.tie(); cin >> n; for(int i = 1 ; i <= n; i++){ char c; cin >> c; A[i % 2][c - 'a']++; } for(int i = 1 ; i <= n; i++){ char c; cin >> c; B[i % 2][c - 'a']++; } for(int i = 0; i < 26; i++) if(A[0][i] != B[0][i] || A[1][i] != B[1][i]){ cout << "NIE"; return 0; } cout << "TAK"; }
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 | #include <iostream> #include <vector> using namespace std; int n, A[2][30], B[2][30]; int main() { ios_base::sync_with_stdio(0); cin.tie(); cin >> n; for(int i = 1 ; i <= n; i++){ char c; cin >> c; A[i % 2][c - 'a']++; } for(int i = 1 ; i <= n; i++){ char c; cin >> c; B[i % 2][c - 'a']++; } for(int i = 0; i < 26; i++) if(A[0][i] != B[0][i] || A[1][i] != B[1][i]){ cout << "NIE"; return 0; } cout << "TAK"; } |