QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#246084#4666. Delete And WincryozwqCompile Error//C++14862b2023-11-10 16:07:492023-11-10 16:07:49

Judging History

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

  • [2023-11-10 16:07:49]
  • 评测
  • [2023-11-10 16:07:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+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++){ 
			ans=min(ans,nxt[now+1][j]-(now+1)+res);
		}
	}
	printf("%d\n",ans);
	return 0;	
}

Details

answer.code:7:9: error: expected initializer before ‘)’ token
    7 | int main){
      |         ^