#include <bits/stdc++.h> using namespace std; int t1[30], t2[30]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, sum1 = 0, sum2 = 0; string s1, s2; bool wyn = true; cin >> n >> s1 >> s2; for(int i = 0; i < n; i++) { t1[s1[i] - 'a']++; t2[s2[i] - 'a']++; } for(int i = 0; i < 26; i++) if(t1[i] != t2[i]) wyn = false; if(wyn == true) { for(int i = 0; i < n; i += 2) { sum1 += s1[i] - 'a'; sum2 += s2[i] - 'a'; } if(sum1 == sum2) cout << "TAK"; else cout << "NIE"; } else cout << "NIE"; }
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 | #include <bits/stdc++.h> using namespace std; int t1[30], t2[30]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, sum1 = 0, sum2 = 0; string s1, s2; bool wyn = true; cin >> n >> s1 >> s2; for(int i = 0; i < n; i++) { t1[s1[i] - 'a']++; t2[s2[i] - 'a']++; } for(int i = 0; i < 26; i++) if(t1[i] != t2[i]) wyn = false; if(wyn == true) { for(int i = 0; i < n; i += 2) { sum1 += s1[i] - 'a'; sum2 += s2[i] - 'a'; } if(sum1 == sum2) cout << "TAK"; else cout << "NIE"; } else cout << "NIE"; } |