#include <iostream> #include <math.h> #include <stdio.h> #include <string> #include <map> #include <stdlib.h> #include <vector> #include <cstring> #include <algorithm> using namespace std; int main() { int numbers; scanf("%d", &numbers); char * tab1 = new char[numbers + 2]; char * tab2 = new char[numbers + 2]; scanf("%s", tab1); scanf("%s", tab2); map<char, int> mapa1p; map<char, int> mapa1n; map<char, int> mapa2p; map<char, int> mapa2n; for (char i= 'a'; i <= 'z'; i++){ mapa1p[i] = 0; mapa2p[i] = 0; mapa1n[i] = 0; mapa2n[i] = 0; } for (int i = 0 ; i < numbers; i++) { if (i % 2 == 0) { mapa1p[tab1[i]]++; mapa2p[tab2[i]]++; } else { mapa1n[tab1[i]]++; mapa2n[tab2[i]]++; } } int correctCounter = 0; for (char i= 'a'; i <= 'z'; i++){ if (mapa1p[i] == mapa2p[i] && mapa1n[i] == mapa2n[i]) { correctCounter++; } } if (correctCounter == 26) { printf("TAK"); } else { printf("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 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 | #include <iostream> #include <math.h> #include <stdio.h> #include <string> #include <map> #include <stdlib.h> #include <vector> #include <cstring> #include <algorithm> using namespace std; int main() { int numbers; scanf("%d", &numbers); char * tab1 = new char[numbers + 2]; char * tab2 = new char[numbers + 2]; scanf("%s", tab1); scanf("%s", tab2); map<char, int> mapa1p; map<char, int> mapa1n; map<char, int> mapa2p; map<char, int> mapa2n; for (char i= 'a'; i <= 'z'; i++){ mapa1p[i] = 0; mapa2p[i] = 0; mapa1n[i] = 0; mapa2n[i] = 0; } for (int i = 0 ; i < numbers; i++) { if (i % 2 == 0) { mapa1p[tab1[i]]++; mapa2p[tab2[i]]++; } else { mapa1n[tab1[i]]++; mapa2n[tab2[i]]++; } } int correctCounter = 0; for (char i= 'a'; i <= 'z'; i++){ if (mapa1p[i] == mapa2p[i] && mapa1n[i] == mapa2n[i]) { correctCounter++; } } if (correctCounter == 26) { printf("TAK"); } else { printf("NIE"); } return 0; } |