QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#700265#4666. Delete And WinfzxWA 0ms3640kbC++141.1kb2024-11-02 12:34:072024-11-02 12:34:13

Judging History

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

  • [2024-11-02 12:34:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3640kb
  • [2024-11-02 12:34:07]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int INF=2e5+5;
string s,t;
int nxt[INF][29],n,m;
void solve() {
    cin>>s>>t;n=s.size();m=t.size();
    s=" "+s;t=" "+t;
    for (int w=0;w<26;w++) nxt[n+1][w]=n+1;
    for (int i=n;i;i--) {
        for (int w=0;w<26;w++) 
            nxt[i][w]=nxt[i+1][w];
        nxt[i][s[i]-'a']=i;
    }
    int res=n,it=0;
    for (int w=0;w<t[1]-'a';w++) {
        if (nxt[it+1][w]>n) continue;
        // if (n-i-(n-nxt[it+1][w]+1)==1) 
        //     cerr<<i<<" "<<(char)(w+'a')<<" QAQ?\n";
        res=min(res,n-(n-nxt[it+1][w]+1));
    }
    for (int i=1;i<m;i++) {
        it=nxt[it+1][t[i]-'a'];
        if (it>n) break;
        res=min(res,n-i);
        for (int w=0;w<t[i+1]-'a';w++) {
            if (nxt[it+1][w]>n) continue;
            // if (n-i-(n-nxt[it+1][w]+1)==1) 
            //     cerr<<i<<" "<<(char)(w+'a')<<" QAQ?\n";
            res=min(res,n-i-(n-nxt[it+1][w]+1));
        }
    }
    cout<<res<<"\n";
}
signed main()
{
    ios::sync_with_stdio(false);
    int t=0;cin>>t;
    while (t--) solve();
    return 0;
}

详细

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements