#include<iostream> #include<string> #include<algorithm> using namespace std; int n; int nparz1[30]; int nparz2[30]; int parz1[30]; int parz2[30]; int main(){ cin >> n; string s; cin >> s; for(int i = 0; i < n; i++){ if(i % 2 == 0) parz1[(int)(s[i] - 'a')]++; else nparz1[(int)(s[i]) - 'a']++; } cin >> s; for(int i = 0; i < n; i++){ if(i % 2 == 0) parz2[(int)(s[i] - 'a')]++; else nparz2[(int)(s[i]) - 'a']++; } for(int i = 0; i < 26; i++){ if(parz1[i] != parz2[i] or nparz1[i] != nparz2[i]){ cout << "NIE"; return 0; } } cout << "TAK"; 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 | #include<iostream> #include<string> #include<algorithm> using namespace std; int n; int nparz1[30]; int nparz2[30]; int parz1[30]; int parz2[30]; int main(){ cin >> n; string s; cin >> s; for(int i = 0; i < n; i++){ if(i % 2 == 0) parz1[(int)(s[i] - 'a')]++; else nparz1[(int)(s[i]) - 'a']++; } cin >> s; for(int i = 0; i < n; i++){ if(i % 2 == 0) parz2[(int)(s[i] - 'a')]++; else nparz2[(int)(s[i]) - 'a']++; } for(int i = 0; i < 26; i++){ if(parz1[i] != parz2[i] or nparz1[i] != nparz2[i]){ cout << "NIE"; return 0; } } cout << "TAK"; return 0; } |