QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245991#4666. Delete And Winrqoi031WA 0ms1560kbC++20776b2023-11-10 15:08:312023-11-10 15:08:58

Judging History

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

  • [2023-11-10 15:08:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1560kb
  • [2023-11-10 15:08:31]
  • 提交

answer

#include<stdio.h>
#include<algorithm>
char s[100005],t[100005];
int next[100005][26];
int main()
{
    scanf("%s%s",s,t);
    const int n(__builtin_strlen(s)),m(__builtin_strlen(t));
    for(int c=0;c<26;c++)
    {
        next[m][c]=m;
    }
    for(int i=m-1;i>=0;i--)
    {
        __builtin_memcpy(next[i],next[i+1],26*sizeof(int));
        next[i][t[i]-'a']=i;
    }
    int ans(m),cur(0);
    for(int i=0,j=0;i<n&&j<m&&cur<ans;i++)
    {
        int nxt(m);
        for(int c=0;c<s[i]-'a';c++)
        {
            nxt=std::min(nxt,next[j][c]);
        }
        ans=std::min(ans,cur+nxt-j);
        nxt=std::min(nxt,next[j][s[i]-'a']);
        cur+=nxt-j,j=nxt+1;
    }
    ans=std::min(ans,cur);
    printf("%d\n",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1560kb

input:

pqsrpspqz
pqrpqz

output:

0

result:

wrong answer 1st numbers differ - expected: '2', found: '0'