QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#245906 | #4666. Delete And Win | Sham_Devour | WA | 0ms | 3896kb | C++14 | 490b | 2023-11-10 14:34:01 | 2023-11-10 14:34:01 |
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,ans=1e9;
int main() {
scanf("%s%s",s+1,t+1);
T=1;n=strlen(s+1);m=strlen(t+1);
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);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3896kb
input:
pqsrpspqz pqrpqz
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'