QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246018#4666. Delete And WinJudgelightWA 1ms3836kbC++14672b2023-11-10 15:30:282023-11-10 15:30:29

Judging History

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

  • [2023-11-10 15:30:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3836kb
  • [2023-11-10 15:30:28]
  • 提交

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;
	for(int i=1,j=1;i<=n;i++){
		if(j>m){ans=min(ans,res);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+1));
	return 0;
}

详细

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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