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
#include <iostream>
#include <string>
#include <vector>
//#include <cmath>

using namespace std;

bool bruteForceIsPalindrome(const char* const str, int const N)
{
    int i = 0;
    int j = N-1;
    while (i < j)
    {
        if (str[i] != str[j])
        {
            //cerr << i <<" "<<str[i]<<" " << j << " " <<str[j] <<" ";
            return false;
        }
        i++; j--;
    }
    return true;
}

int main()
{
    bool isPalindrome = false;
    int N;
    scanf("%d", &N);
    if ((N <= 2000000) && (N > 0))
    {
        char* str;
        str = new char[N];
        scanf("%s", str);
        isPalindrome = bruteForceIsPalindrome(str, N);
        delete[] str;
    }
    else
    {
        string str;
        str.reserve(2000001);
        cin >> str;
        //cout << str;
        isPalindrome = bruteForceIsPalindrome(str.c_str(), str.length());
    }

    if (isPalindrome)
        printf("%s", "TAK");
    else
        printf("%s", "NIE");

    return 0;
}