#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); int N; cin >> N; char t1[N+1]; char t2[N+1]; int tmp1[26][2]; int tmp2[26][2]; for(int i=0; i<26; ++i) for(int j=0; j<2; ++j) tmp1[i][j] = 0, tmp2[i][j] = 0; cin >> t1 >> t2; for(int i=0; i<N; ++i) { tmp1[t1[i]-97][i%2]++; tmp2[t2[i]-97][i%2]++; } for(int i=0; i<26; ++i) { if(tmp1[i][0] != tmp2[i][0]) { cout << "NIE\n"; return 0; } if(tmp1[i][1] != tmp2[i][1]) { cout << "NIE\n"; return 0; } } cout << "TAK\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 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); int N; cin >> N; char t1[N+1]; char t2[N+1]; int tmp1[26][2]; int tmp2[26][2]; for(int i=0; i<26; ++i) for(int j=0; j<2; ++j) tmp1[i][j] = 0, tmp2[i][j] = 0; cin >> t1 >> t2; for(int i=0; i<N; ++i) { tmp1[t1[i]-97][i%2]++; tmp2[t2[i]-97][i%2]++; } for(int i=0; i<26; ++i) { if(tmp1[i][0] != tmp2[i][0]) { cout << "NIE\n"; return 0; } if(tmp1[i][1] != tmp2[i][1]) { cout << "NIE\n"; return 0; } } cout << "TAK\n"; return 0; } |