QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245903#4666. Delete And WinlingyingWA 3ms13624kbC++14624b2023-11-10 14:33:092023-11-10 14:33:09

Judging History

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

  • [2023-11-10 14:33:09]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:13624kb
  • [2023-11-10 14:33:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N=1e5+5;
const int inf=0x3f3f3f3f;

int n,m;
int nxt[N][26];
char s[N],t[N];

int main()
{
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1);m=strlen(t+1);
	memset(nxt,0x3f,sizeof nxt);
	for(int i=m;i>=1;i--)
	{
		for(int j=0;j<26;j++)nxt[i][j]=nxt[i+1][j];
		nxt[i][t[i]-'a']=i;
	}
	int ans=m;
	for(int j=0;j<s[1]-'a';j++)ans=min(ans,nxt[1][j]-1);
	for(int i=1,j=1,c=0;i<n;i++,j++)
	{
		while(j<=m&&s[i]!=t[j])j++,c++;
		if(j>m)break;
		for(int k=0;k<s[i+1]-'a';k++)ans=min(ans,nxt[j+1][k]-j-1+c);
		ans=min(ans,c+m-j);
	}
	cout<<ans;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 13624kb

input:

pqsrpspqz
pqrpqz

output:

0

result:

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