#include <iostream> using namespace std; int parz1[27]; int parz2[27]; int niep1[27]; int niep2[27]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string s1, s2; cin >> s1 >> s2; for(int i=0;i<n;i++){ if(i%2==0){ int a = s1[i] - 'a'; parz1[a]++; int b = s2[i] - 'a'; parz2[b]++; } else{ int a = s1[i] - 'a'; niep1[a]++; int b = s2[i] - 'a'; niep2[b]++; } } bool b=0; for(int i=0;i<=26;i++){ if(parz1[i] != parz2[i]){ b=1; } if(niep1[i] != niep2[i]){ b=1; } } if(b==0){ cout << "TAK"; } else{ cout << "NIE"; } 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 | #include <iostream> using namespace std; int parz1[27]; int parz2[27]; int niep1[27]; int niep2[27]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string s1, s2; cin >> s1 >> s2; for(int i=0;i<n;i++){ if(i%2==0){ int a = s1[i] - 'a'; parz1[a]++; int b = s2[i] - 'a'; parz2[b]++; } else{ int a = s1[i] - 'a'; niep1[a]++; int b = s2[i] - 'a'; niep2[b]++; } } bool b=0; for(int i=0;i<=26;i++){ if(parz1[i] != parz2[i]){ b=1; } if(niep1[i] != niep2[i]){ b=1; } } if(b==0){ cout << "TAK"; } else{ cout << "NIE"; } return 0; } |