#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
int main ()
{
ios_base::sync_with_stdio(0);
int dlug, jest;
string slowo1, slowo2;
int lit1[25];
int lit2[25];
int odl[300000];
jest=1;
for (int n=0; n<25; n++)
{
lit1[n]=0;
lit2[n]=0;
}
for (int n=0; n<300000; n++)
odl[n]=0;
cin >> dlug;
cin >> slowo1;
cin >> slowo2;
int R [ 2 ][ dlug+1 ];
for (int n=0; n<dlug; n++)
{
lit1[slowo1[n]-97]=lit1[slowo1[n]-97]+1;
lit2[slowo2[n]-97]=lit2[slowo2[n]-97]+1;
odl[n]=slowo1[n]-slowo2[n];
}
if (slowo1==slowo2)
cout << "TAK";
else
switch( dlug )
{
case 1:
cout << "NIE";
break;
case 2:
cout << "NIE";
break;
case 3:
if ((slowo1[0]==slowo2[2]) && (slowo1[2]==slowo2[0]))
cout << "TAK";
else
cout << "NIE";
break;
default:
for (int n=0; n<25; n++)
if (lit1[n]!=lit2[n])
jest=0;
if (jest==0)
cout << "NIE";
else
{
jest=0;
// cout << "tutaj";
for (int n=0; n<dlug; n++)
{
// cout << odl[n] << endl;
jest=jest+odl[n];
}
if (jest==0)
cout << "TAK";
else
cout << "NIE";
}
break;
}
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | #include <iostream> #include <cstdio> #include <vector> #include <string> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; int main () { ios_base::sync_with_stdio(0); int dlug, jest; string slowo1, slowo2; int lit1[25]; int lit2[25]; int odl[300000]; jest=1; for (int n=0; n<25; n++) { lit1[n]=0; lit2[n]=0; } for (int n=0; n<300000; n++) odl[n]=0; cin >> dlug; cin >> slowo1; cin >> slowo2; int R [ 2 ][ dlug+1 ]; for (int n=0; n<dlug; n++) { lit1[slowo1[n]-97]=lit1[slowo1[n]-97]+1; lit2[slowo2[n]-97]=lit2[slowo2[n]-97]+1; odl[n]=slowo1[n]-slowo2[n]; } if (slowo1==slowo2) cout << "TAK"; else switch( dlug ) { case 1: cout << "NIE"; break; case 2: cout << "NIE"; break; case 3: if ((slowo1[0]==slowo2[2]) && (slowo1[2]==slowo2[0])) cout << "TAK"; else cout << "NIE"; break; default: for (int n=0; n<25; n++) if (lit1[n]!=lit2[n]) jest=0; if (jest==0) cout << "NIE"; else { jest=0; // cout << "tutaj"; for (int n=0; n<dlug; n++) { // cout << odl[n] << endl; jest=jest+odl[n]; } if (jest==0) cout << "TAK"; else cout << "NIE"; } break; } return 0; } |
English