#include <bits/stdc++.h>
using namespace std;
int n;
bool check(string s1,string s2,int n)
{
int pos;
for(int i=0;i<n;i++){
pos = s2.find(s1[i]);
if(pos!=string::npos){
if(i==pos || abs(pos-i)%2==0){
s2[pos] = s2[pos]-32;
continue;
}
else return false;
}
else return false;
}
return true;
}
int main()
{
cin >> n;
string s1, s2;
cin >> s1 >> s2;
if(check(s1,s2,n))
cout << "TAK";
else cout << "NIE";
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 | #include <bits/stdc++.h> using namespace std; int n; bool check(string s1,string s2,int n) { int pos; for(int i=0;i<n;i++){ pos = s2.find(s1[i]); if(pos!=string::npos){ if(i==pos || abs(pos-i)%2==0){ s2[pos] = s2[pos]-32; continue; } else return false; } else return false; } return true; } int main() { cin >> n; string s1, s2; cin >> s1 >> s2; if(check(s1,s2,n)) cout << "TAK"; else cout << "NIE"; return 0; } |
English