QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#245903 | #4666. Delete And Win | lingying | WA | 3ms | 13624kb | C++14 | 624b | 2023-11-10 14:33:09 | 2023-11-10 14:33:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int inf=0x3f3f3f3f;
int n,m;
int nxt[N][26];
char s[N],t[N];
int main()
{
scanf("%s%s",s+1,t+1);
n=strlen(s+1);m=strlen(t+1);
memset(nxt,0x3f,sizeof nxt);
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);
for(int i=1,j=1,c=0;i<n;i++,j++)
{
while(j<=m&&s[i]!=t[j])j++,c++;
if(j>m)break;
for(int k=0;k<s[i+1]-'a';k++)ans=min(ans,nxt[j+1][k]-j-1+c);
ans=min(ans,c+m-j);
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 13624kb
input:
pqsrpspqz pqrpqz
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'