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
#include <iostream>

using namespace std;
int dlugosc,r,l,r1,l1;
long long suma1,suma2,suma3,suma4;
char x;
int main()
{
    std::ios_base::sync_with_stdio(0);
cin>>dlugosc;
int tp[(dlugosc+1)/2+1];
int tnp[(dlugosc+1)/2+1];
int bp[(dlugosc+1)/2+1];
int bnp[(dlugosc+1)/2+1];
for(int i=1; i<=dlugosc; i++)
{
    cin>>x;
    int pom=x;  
        if(i%2==1)
    {tnp[r]=pom;
    r++;}
        else
    {tp[l]=pom;
    l++;}
}
for(int i=1; i<=dlugosc; i++)
{
    cin>>x;
    int pom=x;  
        if(i%2==1)
    {bnp[r1]=pom;
    r1++;}
        else
    {bp[l1]=pom;
    l1++;}
}
for(int i=0; i<=l-1; i++)
{suma1+=tp[i];
suma3+=bp[i];}

for(int i=0; i<=r-1; i++)
{suma2+=tnp[i];
suma4+=bnp[i];}

if(suma2==suma4 && suma1==suma3)
cout<<"TAK";
else
cout<<"NIE";
    return 0;
}