QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#558005#8668. 回文路径zero-range0 24ms9792kbC++201.6kb2024-09-11 13:27:272024-09-11 13:27:27

Judging History

你现在查看的是最新测评结果

  • [2024-09-11 13:27:27]
  • 评测
  • 测评结果:0
  • 用时:24ms
  • 内存:9792kb
  • [2024-09-11 13:27:27]
  • 提交

answer

#include<stdio.h>
#include<algorithm>
#define M 200005
using namespace std;
typedef unsigned long long ull;
constexpr ull bs=1000;
ull Ha[M],Hb[M],Pa[M],Pb[M],pw[M];
inline ull queh(ull *H,int l,int r){return H[r]-H[l-1]*pw[r-l+1];}
inline ull quep(ull *P,int l,int r){return P[l]-P[r+1]*pw[r-l+1];}
int n,res;
char a[M],b[M];
int main(){
	pw[0]=1;
	for(int i=1;i<M;++i) pw[i]=pw[i-1]*bs;
	scanf("%d%s%s",&n,a+1,b+1);
	for(int i=n;i;--i) a[i*2]=a[i],a[i*2+1]='#';
	a[1]='#';
	for(int i=n;i;--i) b[i*2+1]=b[i],b[i*2+2]='#';
	b[1]='@',b[2]='#',a[n=n*2+2]='.';
	puts(a+1),puts(b+1);
	for(int i=1;i<=n;++i) Ha[i]=Ha[i-1]*bs+a[i];
	for(int i=n;i;--i) Pa[i]=Pa[i+1]*bs+a[i];
	for(int i=1;i<=n;++i) Hb[i]=Hb[i-1]*bs+b[i];
	for(int i=n;i;--i) Pb[i]=Pb[i+1]*bs+b[i];
	for(int i=1;i<=n;++i){
		int l=1,r=min(i-1,n-i),mid,ans=0;
		while(l<=r){
			mid=l+r>>1;
			if(queh(Ha,i-mid,i-1)==quep(Pa,i+1,i+mid)) l=mid+1,ans=mid;
			else r=mid-1;
		}
		int t=ans;
		res=max(res,t*2+1);
		l=1,r=min(i-t-1,n-i+1-t),ans=0;
		while(l<=r){
			mid=l+r>>1;
			if(queh(Ha,i-t-mid,i-t-1)==quep(Pb,i+t,i+t+mid-1)) l=mid+1,ans=mid;
			else r=mid-1;
		}
		res=max(res,(t+ans)*2+1);
	}
	for(int i=1;i<=n;++i){
		int l=1,r=min(i-1,n-i),mid,ans=0;
		while(l<=r){
			mid=l+r>>1;
			if(queh(Hb,i-mid,i-1)==quep(Pb,i+1,i+mid)) l=mid+1,ans=mid;
			else r=mid-1;
		}
		int t=ans;
		res=max(res,t*2+1);
		l=1,r=min(i-t,n-i-t),ans=0;
		while(l<=r){
			mid=l+r>>1;
			if(queh(Ha,i-t-mid+1,i-t)==quep(Pb,i+t+1,i+t+mid)) l=mid+1,ans=mid;
			else r=mid-1;
		}
		res=max(res,(t+ans)*2+1);
	}
	printf("%d",res/2);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3748kb

input:

1000
mfmlkrasfiudkzrjzyrlbpitvzfrlmjdzsurtdcmnqpsyfgobbstvplqylvciloomaljyssxtrrccywyirfvlcnchwkfwbdaoxzpfpvlruptganojnfxmnlqetptmlmoyluxvaipghtlaszoozscdmjomobyzboqqmvqjpbfjsoczhkwrlcauzjceqikbaeuiqahnldpqmohfjfzgkbfdbqnoxispkejvpncwsyelebqumapgbfdrjvuaxaphnkciwzkruijmanwslkwosgyfhwbnsthhtxrhrzlgtt...

output:

#m#f#m#l#k#r#a#s#f#i#u#d#k#z#r#j#z#y#r#l#b#p#i#t#v#z#f#r#l#m#j#d#z#s#u#r#t#d#c#m#n#q#p#s#y#f#g#o#b#b#s#t#v#p#l#q#y#l#v#c#i#l#o#o#m#a#l#j#y#s#s#x#t#r#r#c#c#y#w#y#i#r#f#v#l#c#n#c#h#w#k#f#w#b#d#a#o#x#z#p#f#p#v#l#r#u#p#t#g#a#n#o#j#n#f#x#m#n#l#q#e#t#p#t#m#l#m#o#y#l#u#x#v#a#i#p#g#h#t#l#a#s#z#o#o#z#s#c#d#m...

result:

wrong answer 1st lines differ - expected: '6', found: '#m#f#m#l#k#r#a#s#f#i#u#d#k#z#r...o#h#f#v#y#v#g#r#p#x#t#m#d#v#e#.'

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 24ms
memory: 9792kb

input:

100000
ibhqhodaqcwqggmckoemulhkgbfidceskhefhsonccepfodalabaqgobpgcnaervbccadkbtsdigsoqochklocgbjjqcdhwrlacamprsoilyhiwkkjalicedhbxajrkhjgivjhnfdibkdwtexnnriegejazmohlfijbeigfmpngncokxhifjfuwuogccdfglfbxobnarmgfhgpnjjewicgfhcmfbbnjbbjjtbprnagpchcihcihfhcikeaecefdgeegtzlfdolhfieahiehdfcaflmndmcojceblf...

output:

#i#b#h#q#h#o#d#a#q#c#w#q#g#g#m#c#k#o#e#m#u#l#h#k#g#b#f#i#d#c#e#s#k#h#e#f#h#s#o#n#c#c#e#p#f#o#d#a#l#a#b#a#q#g#o#b#p#g#c#n#a#e#r#v#b#c#c#a#d#k#b#t#s#d#i#g#s#o#q#o#c#h#k#l#o#c#g#b#j#j#q#c#d#h#w#r#l#a#c#a#m#p#r#s#o#i#l#y#h#i#w#k#k#j#a#l#i#c#e#d#h#b#x#a#j#r#k#h#j#g#i#v#j#h#n#f#d#i#b#k#d#w#t#e#x#n#n#r#i#e...

result:

wrong answer 1st lines differ - expected: '9', found: '#i#b#h#q#h#o#d#a#q#c#w#q#g#g#m...l#h#m#e#e#f#b#n#u#k#v#v#e#h#k#.'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%