下载数据了,DEC c++ 和落谷IDE 都能过,就不知道为啥报错.。。
#include<bits/stdc++.h>
using namespace std;
const int N=2e7+5;
char a[N],b[N*2],s[N];
int n,p,q,nextt[N],z,P,x;
int main()
{
cin>>a>>b;
nextt[0]=strlen(b);
x=strlen(b)+1;
strcat(b,"#");
strcat(b,a);
n=strlen(b);
for(int i=1;i<n;i++)
{
if((i>=p)||(i+nextt[i-q]>=p))
{
if(i>=p) p=i;
while((p<n)&&(b[p]==b[p-i])) p++;
nextt[i]=p-i;
q=i;
}
else nextt[i]=nextt[i-q];
}
for(int i=0;i<x-1;i++)
{
z^=(i+1)*(nextt[i]+1);
}
for(int i=0;i<n-x;i++)
{
P^=(i+1)*(nextt[i+x]+1);
}
cout<<z<<" "<<P;
}