#include<bits/stdc++.h> #define f first #define s second #define mp make_pair #define pb push_back #define pii pair<int, int> #define pll pair<long long, long long> #define ll long long #define vi vector<int> #define vl vector<ll> #define rep(i,p,k) for(ll i=p; i<k; i++) #define per(i,p,k) for (ll i=k-1;i>=p;i--) ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;} using namespace std; int pnp[30][2]; int pnp2[30][2]; int main() { int n; cin >> n; string a, b; cin >> a >> b; rep(i, 0, a.size()) { pnp[a[i]-'a'][i%2]++; } rep(i, 0, b.size()) { pnp2[b[i]-'a'][i%2]++; } bool czy = true; rep(i, 0, 26) { rep(j, 0, 2) { if(pnp[i][j] != pnp2[i][j]) { czy = false; } } } if(czy) cout<<"TAK"; 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 33 34 35 36 37 38 39 40 41 42 43 44 | #include<bits/stdc++.h> #define f first #define s second #define mp make_pair #define pb push_back #define pii pair<int, int> #define pll pair<long long, long long> #define ll long long #define vi vector<int> #define vl vector<ll> #define rep(i,p,k) for(ll i=p; i<k; i++) #define per(i,p,k) for (ll i=k-1;i>=p;i--) ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;} using namespace std; int pnp[30][2]; int pnp2[30][2]; int main() { int n; cin >> n; string a, b; cin >> a >> b; rep(i, 0, a.size()) { pnp[a[i]-'a'][i%2]++; } rep(i, 0, b.size()) { pnp2[b[i]-'a'][i%2]++; } bool czy = true; rep(i, 0, 26) { rep(j, 0, 2) { if(pnp[i][j] != pnp2[i][j]) { czy = false; } } } if(czy) cout<<"TAK"; else cout<<"NIE"; } |