#include <iostream> #include <stdio.h> #include <vector> using namespace std; int main(){ int n; cin >> n; if (n>0){ if (n < 2400){ string str; cin >> str; bool pal = true; for (int i = 0; i < (int)str.length()/2; ++i){ if (str[i]!=str[str.length()-i-1]){ pal = false; break; } } if (pal==false) cout << "NIE" << endl; else cout << "TAK" << endl; } else{ char t1[1200], t2[1200]; bool pal = true; for (int i = 0; i < 1200; ++i) t1[i] = getchar(); for (int i = 0; i < n-2400; ++i) getchar(); for (int i = 0; i < 1200; ++i) t2[i] = getchar(); for (int i =0; i < 1200; ++i){ if (t1[i]!=t2[1199-i]) pal = false; } if (pal==false) cout << "NIE" << endl; else cout << "TAK" << endl; } } else{ vector <char> v1, v2; char c = getchar(); while (c == '\n') c = getchar(); while ((v1.size() < 1200) && (c != EOF) && (c != '\n') && (c != ' ')){ v1.push_back(c); c = getchar(); } if (v1.size() < 1200){ bool pal = true; for (int i = 0; i < ((int)v1.size())/2; ++i){ if (v1[i] != v1[v1.size()-i-1]) pal = false; } if (pal==false) cout << "NIE" << endl; else cout << "TAK" << endl; } else{ bool pal = true; while ((c != EOF) && (c != '\n') && (c != ' ')){ if (v2.size() >= 1200) v2.erase(v2.begin()); v2.push_back(c); c = getchar(); } for (int i = 0; i < (int)v2.size(); ++i) v1.push_back(v2[i]); for (int i = 0; i < ((int)v1.size())/2; ++i){ if (v1[i] != v1[v1.size()-i-1]) pal = false; } if (pal==false) cout << "NIE" << endl; else cout << "TAK" << endl; } } 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 | #include <iostream> #include <stdio.h> #include <vector> using namespace std; int main(){ int n; cin >> n; if (n>0){ if (n < 2400){ string str; cin >> str; bool pal = true; for (int i = 0; i < (int)str.length()/2; ++i){ if (str[i]!=str[str.length()-i-1]){ pal = false; break; } } if (pal==false) cout << "NIE" << endl; else cout << "TAK" << endl; } else{ char t1[1200], t2[1200]; bool pal = true; for (int i = 0; i < 1200; ++i) t1[i] = getchar(); for (int i = 0; i < n-2400; ++i) getchar(); for (int i = 0; i < 1200; ++i) t2[i] = getchar(); for (int i =0; i < 1200; ++i){ if (t1[i]!=t2[1199-i]) pal = false; } if (pal==false) cout << "NIE" << endl; else cout << "TAK" << endl; } } else{ vector <char> v1, v2; char c = getchar(); while (c == '\n') c = getchar(); while ((v1.size() < 1200) && (c != EOF) && (c != '\n') && (c != ' ')){ v1.push_back(c); c = getchar(); } if (v1.size() < 1200){ bool pal = true; for (int i = 0; i < ((int)v1.size())/2; ++i){ if (v1[i] != v1[v1.size()-i-1]) pal = false; } if (pal==false) cout << "NIE" << endl; else cout << "TAK" << endl; } else{ bool pal = true; while ((c != EOF) && (c != '\n') && (c != ' ')){ if (v2.size() >= 1200) v2.erase(v2.begin()); v2.push_back(c); c = getchar(); } for (int i = 0; i < (int)v2.size(); ++i) v1.push_back(v2[i]); for (int i = 0; i < ((int)v1.size())/2; ++i){ if (v1[i] != v1[v1.size()-i-1]) pal = false; } if (pal==false) cout << "NIE" << endl; else cout << "TAK" << endl; } } return 0; } |