#include <bits/stdc++.h> using namespace std; #define debug(x) cerr << #x << " " << x << endl; #define int long long // uważaj const int N = 1e6 + 7; int t[50]; bool test(string s1, string s2) { for(int i = 0; i < 50; i++) { t[i] = 0; } for(int i = 0; i < s1.size(); i+=2) { t[s1[i] - 'a'] ++; t[s2[i] - 'a'] --; } for(int i = 0; i < 50; i++) { if(t[i] != 0) return false; } return true; } void solve(){ int n; string s1, s2; cin >> n >> s1 >> s2; bool ok = true; ok = (ok && test(s1, s2)); reverse(s1.begin(), s1.end()); reverse(s2.begin(), s2.end()); s1.pop_back(); s2.pop_back(); reverse(s1.begin(), s1.end()); reverse(s2.begin(), s2.end()); ok = (ok && test(s1, s2)); if(ok) { cout << "TAK\n"; } else { cout << "NIE\n"; } } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int test = 1; while(test--){ solve(); } 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 60 61 62 | #include <bits/stdc++.h> using namespace std; #define debug(x) cerr << #x << " " << x << endl; #define int long long // uważaj const int N = 1e6 + 7; int t[50]; bool test(string s1, string s2) { for(int i = 0; i < 50; i++) { t[i] = 0; } for(int i = 0; i < s1.size(); i+=2) { t[s1[i] - 'a'] ++; t[s2[i] - 'a'] --; } for(int i = 0; i < 50; i++) { if(t[i] != 0) return false; } return true; } void solve(){ int n; string s1, s2; cin >> n >> s1 >> s2; bool ok = true; ok = (ok && test(s1, s2)); reverse(s1.begin(), s1.end()); reverse(s2.begin(), s2.end()); s1.pop_back(); s2.pop_back(); reverse(s1.begin(), s1.end()); reverse(s2.begin(), s2.end()); ok = (ok && test(s1, s2)); if(ok) { cout << "TAK\n"; } else { cout << "NIE\n"; } } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int test = 1; while(test--){ solve(); } return 0; } |