QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245940#4666. Delete And WinFiyulsWA 1ms5696kbC++14606b2023-11-10 14:42:442023-11-10 14:42:44

Judging History

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

  • [2023-11-10 14:42:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5696kb
  • [2023-11-10 14:42:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char S[maxn],T[maxn];
int n,m,ans=1e8,Bakward[maxn][26];
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++){
			Bakward[i][j]=(i!=m?Bakward[i+1][j]:m+1);	
		}
		Bakward[i][T[i]-'a']=i;
	}
	for(int i=1,pos=0,sum=0;(i<=n&&pos<=m);i++){
		int Themin=m+1;
		for(int j=0;j<(S[i]-'a');j++){
			Themin=min(Themin,Bakward[pos+1][j]);
		}
		ans=min(ans,sum+Themin-pos-1),sum+=Bakward[pos+1][S[i]-'a']-pos-1,pos=Bakward[pos+1][S[i]-'a'];
	}
	cout<<ans;return 0;
}

詳細信息

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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