QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245895#4666. Delete And WinRainWA 0ms3704kbC++14781b2023-11-10 14:31:402023-11-10 14:31:41

Judging History

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

  • [2023-11-10 14:31:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3704kb
  • [2023-11-10 14:31:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,m,ans=1e9,s[N][30];
char a[N],b[N];
int main(){
	scanf("%s%s",a+1,b+1);
	n=strlen(a+1),m=strlen(b+1);
	for(int i=1;i<=m;++i){
		for(int j=1;j<=26;++j){
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(b[i]-'a'+1==j);
		}
	}
	for(int i=1,j=0,res=0;i<=n&&j<=m&&res<ans;++i){
		int l=j+1,r=m,p=m+1;
		while(l<=r){
			int mid=l+r>>1;
			if(s[mid][a[i]-'a']-s[j][a[i]-'a']>0) r=mid-1,p=mid;
			else l=mid+1;
		}
		ans=min(ans,res+p-j-1);
		l=j+1,r=p-1;
		p=m+1;
		while(l<=r){
			int mid=l+r>>1;
			if(s[mid][a[i]-'a'+1]-s[mid][a[i]-'a']-s[j][a[i]-'a'+1]+s[j][a[i]-'a']>0) p=mid,r=mid-1;
			else l=mid+1;
		}
		res+=p-j-1;
		j=p;
	}
	printf("%d",ans);
	return 0;
}

詳細信息

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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