#include <iostream> #include <string> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s1,s2; vector<int> a1,a2,a3,a4; for(int i = 0;i < 26;i++) { a1.push_back(0); a2.push_back(0); a3.push_back(0); a4.push_back(0); } cin >> s1 >> s2; for(int i = 0;i < n;i++) { if(i%2==0) { a1[(int(s1[i]) - 97)]++; a2[(int(s2[i]) - 97)]++; } else { a3[(int(s1[i]) - 97)]++; a4[(int(s2[i]) - 97)]++; } } for(int i = 0;i < 26;i++) { if(a1[i] != a2[i] || a3[i] != a4[i]) { 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 | #include <iostream> #include <string> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s1,s2; vector<int> a1,a2,a3,a4; for(int i = 0;i < 26;i++) { a1.push_back(0); a2.push_back(0); a3.push_back(0); a4.push_back(0); } cin >> s1 >> s2; for(int i = 0;i < n;i++) { if(i%2==0) { a1[(int(s1[i]) - 97)]++; a2[(int(s2[i]) - 97)]++; } else { a3[(int(s1[i]) - 97)]++; a4[(int(s2[i]) - 97)]++; } } for(int i = 0;i < 26;i++) { if(a1[i] != a2[i] || a3[i] != a4[i]) { cout << "NIE" << "\n"; return 0; } } cout << "TAK" << "\n"; return 0; } |