#include <iostream> #include <vector> using namespace std; int main(){ cin.tie(0);cout.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; string a,b; cin >> a >> b; vector <int> P(26,0), NP(26,0), P1(26,0), NP1(26,0); for(int i=0;i<n;i++){ if(i%2==0){ P[a[i]-'a']++; P1[b[i]-'a']++; } else{ NP[a[i]-'a']++; NP1[b[i]-'a']++; } } if(P1==P && NP == NP1)cout << "TAK" << '\n'; else cout << "NIE" << '\n'; }
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 | #include <iostream> #include <vector> using namespace std; int main(){ cin.tie(0);cout.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; string a,b; cin >> a >> b; vector <int> P(26,0), NP(26,0), P1(26,0), NP1(26,0); for(int i=0;i<n;i++){ if(i%2==0){ P[a[i]-'a']++; P1[b[i]-'a']++; } else{ NP[a[i]-'a']++; NP1[b[i]-'a']++; } } if(P1==P && NP == NP1)cout << "TAK" << '\n'; else cout << "NIE" << '\n'; } |