QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#245940 | #4666. Delete And Win | Fiyuls | WA | 1ms | 5696kb | C++14 | 606b | 2023-11-10 14:42:44 | 2023-11-10 14:42:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char S[maxn],T[maxn];
int n,m,ans=1e8,Bakward[maxn][26];
int main(){
scanf("%s%s",(S+1),(T+1)),n=strlen(S+1),m=strlen(T+1);
for(int i=m;i>=1;i--){
for(int j=0;j<26;j++){
Bakward[i][j]=(i!=m?Bakward[i+1][j]:m+1);
}
Bakward[i][T[i]-'a']=i;
}
for(int i=1,pos=0,sum=0;(i<=n&&pos<=m);i++){
int Themin=m+1;
for(int j=0;j<(S[i]-'a');j++){
Themin=min(Themin,Bakward[pos+1][j]);
}
ans=min(ans,sum+Themin-pos-1),sum+=Bakward[pos+1][S[i]-'a']-pos-1,pos=Bakward[pos+1][S[i]-'a'];
}
cout<<ans;return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5696kb
input:
pqsrpspqz pqrpqz
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'