QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#245936 | #4666. Delete And Win | Sham_Devour | Compile Error | / | / | C++14 | 488b | 2023-11-10 14:41:32 | 2023-11-10 14:41:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char s[N],t[N];
int f[N],g[30],T;
int n,m;
int main() {
scanf("%s%s",t+1,s+1);
T=1;n=strlen(s+1);m=strlen(t+1);ans=m;
for(int i=1;i<=n;i++) f[i]=-1;
for(int i=1;i<=m;i++)
if(t[i]==s[T]) f[T++]=i;
int pos=m;
for(int i=n-1;i>=0;i--) {
if(f[i]==-1) continue;
while(pos>f[i]) g[t[pos]-'a']=pos,pos--;
for(int j=0;j<s[i+1]-'a';j++)
if(g[j]!=0) ans=min(ans,g[j]-i-1);
}
printf("%d",ans);
}
详细
answer.code: In function ‘int main()’: answer.code:9:41: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 9 | T=1;n=strlen(s+1);m=strlen(t+1);ans=m; | ^~~ | abs answer.code:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%s%s",t+1,s+1); | ~~~~~^~~~~~~~~~~~~~~~