#include<bits/stdc++.h> typedef long long ll; typedef std::pair<ll, ll> pll; typedef std::pair<int, int> pii; #define all(x) (x).begin(),(x).end() #define debug std::cout<<"ok"<<std::endl main () { int n; std::cin>>n; std::vector<std::vector<int> > V1(26, {0,0}), V2(26,{0,0}); std::string S; std::cin>>S; for (int i=0; i<S.size(); i++) V1[S[i]-'a'][i%2]++; std::cin>>S; for (int i=0; i<S.size(); i++) V2[S[i]-'a'][i%2]++; bool R=1; for (int i=0; i<26; i++) if (V1[i][0]!=V2[i][0] || V1[i][1]!=V2[i][1]) R=0; if (R) std::cout<<"TAK"<<std::endl; else std::cout<<"NIE"<<std::endl; }
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 | #include<bits/stdc++.h> typedef long long ll; typedef std::pair<ll, ll> pll; typedef std::pair<int, int> pii; #define all(x) (x).begin(),(x).end() #define debug std::cout<<"ok"<<std::endl main () { int n; std::cin>>n; std::vector<std::vector<int> > V1(26, {0,0}), V2(26,{0,0}); std::string S; std::cin>>S; for (int i=0; i<S.size(); i++) V1[S[i]-'a'][i%2]++; std::cin>>S; for (int i=0; i<S.size(); i++) V2[S[i]-'a'][i%2]++; bool R=1; for (int i=0; i<26; i++) if (V1[i][0]!=V2[i][0] || V1[i][1]!=V2[i][1]) R=0; if (R) std::cout<<"TAK"<<std::endl; else std::cout<<"NIE"<<std::endl; } |