#include<bits/stdc++.h>
#include"palindromy.h"
#include"message.h"
using namespace std;
vector<char> s;
int tab[1000009];
int main()
{
	int n=GetLength(),a=0,b;
	char c;
	for(int i=0; i<n; i++)
	{
		c=GetLetter(i);
		s.push_back(c);
		s.push_back(c);
	}
	n*=2;
	long long wyn=0;
	while(a<n)
	{
		while(s[a-tab[a]-1]==s[a+tab[a]])
		{
			tab[a]++;
			if(a-tab[a]<=0 || a+tab[a]>=n) break;
		}
		b=a+1;
		while(b<=a+tab[a])
		{
			if(b-a+tab[2*a-b]!=tab[a])
			{
				if(b-a+tab[2*a-b]<tab[a]) tab[b]=tab[2*a-b];
				else tab[b]=tab[a]+a-b;
			}
			else
			{
				tab[b]=tab[a]+a-b;
				break;
			}
			b++;
		}
		a=b;
	}
	for(int i=0; i<n; i++) wyn+=tab[i];
	wyn-=(n/2);
	wyn=(wyn%2)+(wyn/2);
	wyn+=(n/2);
	if(MyNodeId()==0) cout<<wyn;
	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 | #include<bits/stdc++.h> #include"palindromy.h" #include"message.h" using namespace std; vector<char> s; int tab[1000009]; int main() { int n=GetLength(),a=0,b; char c; for(int i=0; i<n; i++) { c=GetLetter(i); s.push_back(c); s.push_back(c); } n*=2; long long wyn=0; while(a<n) { while(s[a-tab[a]-1]==s[a+tab[a]]) { tab[a]++; if(a-tab[a]<=0 || a+tab[a]>=n) break; } b=a+1; while(b<=a+tab[a]) { if(b-a+tab[2*a-b]!=tab[a]) { if(b-a+tab[2*a-b]<tab[a]) tab[b]=tab[2*a-b]; else tab[b]=tab[a]+a-b; } else { tab[b]=tab[a]+a-b; break; } b++; } a=b; } for(int i=0; i<n; i++) wyn+=tab[i]; wyn-=(n/2); wyn=(wyn%2)+(wyn/2); wyn+=(n/2); if(MyNodeId()==0) cout<<wyn; return 0; } | 
 
            
         English
                    English