QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245906#4666. Delete And WinSham_DevourWA 0ms3896kbC++14490b2023-11-10 14:34:012023-11-10 14:34:01

Judging History

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

  • [2023-11-10 14:34:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3896kb
  • [2023-11-10 14:34:01]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char s[N],t[N];
int f[N],g[30],T;
int n,m,ans=1e9;
int main() {
	scanf("%s%s",s+1,t+1);
	T=1;n=strlen(s+1);m=strlen(t+1);
	for(int i=1;i<=n;i++) f[i]=-1;
	for(int i=1;i<=m;i++)
		if(t[i]==s[T]) f[T++]=i;
	int pos=m;
	for(int i=n-1;i>=0;i--) {
		if(f[i]==-1) continue;
		while(pos>f[i]) g[t[pos]-'a']=pos,pos--;
		for(int j=0;j<s[i+1]-'a';j++) 
			if(g[j]!=0) ans=min(ans,g[j]-i-1);
	}
	printf("%d",ans); 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3896kb

input:

pqsrpspqz
pqrpqz

output:

0

result:

wrong answer 1st numbers differ - expected: '2', found: '0'