#include <cstdio> #include <string> int main() { bool result = true; int n; std::string s; scanf("%d", &n); while (getchar() != '\n'); if (n > 0) { for (int i = 0; i < n / 2; ++i) { s.push_back(getchar()); } if (n % 2) { getchar(); } for (int i = n / 2 - 1; i >= 0 / 2; --i) { if (s[i] != getchar()) { result = false; break; } } } else { char c; while ((c = getchar()) >= 'a' && c <= 'z') { s.push_back(c); } n = s.length(); for (int i = 0; i < n / 2; ++i) { if (s[i] != s[n - i - 1]) { result = false; break; } } } printf("%s\n", result ? "TAK" : "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 | #include <cstdio> #include <string> int main() { bool result = true; int n; std::string s; scanf("%d", &n); while (getchar() != '\n'); if (n > 0) { for (int i = 0; i < n / 2; ++i) { s.push_back(getchar()); } if (n % 2) { getchar(); } for (int i = n / 2 - 1; i >= 0 / 2; --i) { if (s[i] != getchar()) { result = false; break; } } } else { char c; while ((c = getchar()) >= 'a' && c <= 'z') { s.push_back(c); } n = s.length(); for (int i = 0; i < n / 2; ++i) { if (s[i] != s[n - i - 1]) { result = false; break; } } } printf("%s\n", result ? "TAK" : "NIE"); return 0; } |