QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245907#4666. Delete And WincryozwqWA 1ms5900kbC++14922b2023-11-10 14:34:172023-11-10 14:34:19

Judging History

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

  • [2023-11-10 14:34:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5900kb
  • [2023-11-10 14:34:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int nxt[maxn][26];
char s[maxn],t[maxn];
int n,m;
int main(){
//	freopen("string.in","r",stdin);
//	freopen("string.out","w",stdout);
	scanf("%s",t+1);
	scanf("%s",s+1);
	int n=strlen(s+1);
	int m=strlen(t+1);
	for(int j=0;j<26;j++)nxt[m+1][j]=m+1;
	for(int i=m;i>=1;i--){
		for(int j=0;j<26;j++)nxt[i][j]=nxt[i+1][j];
		nxt[i][t[i]-'a']=i;
	}
	int ans=m;
	for(int j=0;j<s[1]-'a';j++)ans=min(ans,nxt[1][j]-1);
//	cout<<ans<<endl;
	int now=0;
	int res=0;
	for(int i=1;i<n;i++){
		now++;
		res+=(nxt[now][s[i]-'a']-now);
		now=nxt[now][s[i]-'a'];
		if(now==m+1||now==m)break;
		ans=min(ans,m-now+res);
//		cout<<"res"<<res<<" "<<now<<endl;
		for(int j=0;j<(s[i+1]-'a');j++){
			cout<<now<<" "<<j<<" "<<nxt[now+1][j]-(now+1)<<" "<<endl;
			ans=min(ans,nxt[now+1][j]-(now+1)+res);
		}
	}
	printf("%d\n",ans);
	return 0;	
}

詳細信息

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

1 0 8 
1 1 8 
1 2 8 
1 3 8 
1 4 8 
1 5 8 
1 6 8 
1 7 8 
1 8 8 
1 9 8 
1 10 8 
1 11 8 
1 12 8 
1 13 8 
1 14 8 
1 15 3 
2 0 7 
2 1 7 
2 2 7 
2 3 7 
2 4 7 
2 5 7 
2 6 7 
2 7 7 
2 8 7 
2 9 7 
2 10 7 
2 11 7 
2 12 7 
2 13 7 
2 14 7 
2 15 2 
2 16 5 
4 0 5 
4 1 5 
4 2 5 
4 3 5 
4 4 5 
4 5 5 
4 6 5 
4 7 5 
...

result:

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