QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#700265 | #4666. Delete And Win | fzx | WA | 0ms | 3640kb | C++14 | 1.1kb | 2024-11-02 12:34:07 | 2024-11-02 12:34:13 |
Judging History
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