#include <bits/stdc++.h> #define ff first #define ss second #define ll long long #define N 100010 #define deb 0 using namespace std; int ile[2][150]; int main() { if(!deb){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n; char c; cin >> n; for(int i=0;i<n;i++) { cin >> c; ile[i%2][c]++; } for(int i=0;i<n;i++) { cin >> c; ile[i%2][c]--; } for(int i='a'; i<='z'; i++) { if(deb)printf("Znak %c -> %d %d\n", i, ile[0][i], ile[1][i]); if(ile[0][i]!=0 || ile[1][i]!=0) { cout << "NIE" << endl; return 0; } } cout << "TAK" << endl; 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 | #include <bits/stdc++.h> #define ff first #define ss second #define ll long long #define N 100010 #define deb 0 using namespace std; int ile[2][150]; int main() { if(!deb){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n; char c; cin >> n; for(int i=0;i<n;i++) { cin >> c; ile[i%2][c]++; } for(int i=0;i<n;i++) { cin >> c; ile[i%2][c]--; } for(int i='a'; i<='z'; i++) { if(deb)printf("Znak %c -> %d %d\n", i, ile[0][i], ile[1][i]); if(ile[0][i]!=0 || ile[1][i]!=0) { cout << "NIE" << endl; return 0; } } cout << "TAK" << endl; return 0; } |