QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245973#4666. Delete And WinhhhgjyWA 0ms3612kbC++14634b2023-11-10 14:55:112023-11-10 14:55:11

Judging History

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

  • [2023-11-10 14:55:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2023-11-10 14:55:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int N,M;char s[100005],t[100005];
int nxt[100005][26],res;
int calc(int p,int ch){return (nxt[p][ch]-p);}
int main(){
    scanf("%s%s",t+1,s+1);N=strlen(s+1),M=strlen(t+1);res=N;
    for(int i=0;i<26;++i)nxt[N+1][i]=N+1;
	for(int i=N;i>=1;--i){
    	for(int j=0;j<26;++j)nxt[i][j]=nxt[i+1][j];
    	int now=(s[i]-'a');
		for(int j=now+1;j<26;++j)nxt[i][j]=i; 
	}
	res=min(res,calc(1,(int)(t[1]-'a')));int lst=0;
	for(int i=1;i<M;++i){
		++lst;while(lst<=N&&s[lst]!=t[i])++lst;
		if(lst>N)break;res=min(res,lst-i+calc(lst+1,(int)(t[i+1]-'a')));
	} cout<<res;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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