QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246114#4666. Delete And WinJudgelightWA 0ms3864kbC++14636b2023-11-10 16:17:422023-11-10 16:17:43

Judging History

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

  • [2023-11-10 16:17:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3864kb
  • [2023-11-10 16:17:42]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N=1e5+10;
char s[N],t[N];
int nex[N][26];
int n,m,ans;
int main(){
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1),m=strlen(t+1);
	for(int i=m;i>=1;--i){
		for(int j=0;j<26;++j)nex[i][j]=nex[i+1][j];
		nex[i][t[i]-'a']=i;
	}
	for(int i=0;i<26;++i)nex[0][i]=nex[1][i];
	ans=m;
	for(int i=1,j=1,c=0;i<=n;++i){
		for(int k=s[i]-'a'-1;k>=0;--k)
			if(nex[j][k])
				ans=min(ans,c+nex[j][k]-j);
		if(nex[j][s[i]-'a'])c+=nex[j][s[i]-'a']-j,j=nex[j][s[i]-'a']+1;
		else break;
		ans=min(ans,m-j+1+c);
	}
	printf("%d\n",ans);
	return 0;
}

詳細信息

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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