QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246123#4666. Delete And WinJudgelightWA 0ms3880kbC++14657b2023-11-10 16:22:362023-11-10 16:22:37

Judging History

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

  • [2023-11-10 16:22:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3880kb
  • [2023-11-10 16:22:36]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define eb emplace_back
#define mk make_pair
#define N 100009
using namespace std;
int n,m,p[N][26];char s[N],t[N];
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	scanf("%s",t+1),m=strlen(t+1);
	for(int i=0;i<26;i++)p[m+1][i]=m+1;
	for(int i=m;i>=1;i--){
		for(int j=0;j<26;j++)p[i][j]=p[i+1][j];
		p[i][t[i]-'a']=i;
	}
	int ans=m;
	int res=0,j=1;
	for(int i=1;i<=n;i++){
		if(j>m)break;
		int nw=m+1;
		for(int l=0;l<s[i]-'a';l++)nw=min(nw,p[j][l]);
		if(nw!=m+1)ans=min(ans,res+nw-j);
		while(j<=m&&s[i]!=t[j])j++,res++;
		if(j<=m)j++;
	}
	printf("%d",min(ans,res+m-j+2));
	return 0;
}

詳細信息

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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