QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#700728 | #4666. Delete And Win | Cure_Beauty | WA | 0ms | 3560kb | C++14 | 966b | 2024-11-02 13:20:17 | 2024-11-02 13:20:53 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using std::cin;using std::cout;
constexpr int S=26;
int t,ans,now;
std::string a,b;
std::queue<int>g[S];
signed main(){
// freopen("string.in","r",stdin);
// freopen("string.out","w",stdout);
std::ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
for(cin>>t;t--;cout<<ans<<'\n'){
cin>>a>>b;ans=1e9;now=0;bool t1=1;
for(int i=0;i<a.size();++i) g[a[i]-'a'].push(i);
for(int i=0,k=0;i<b.size();++i,++k){
for(int j=0;j<b[i]-'a';++j) if(g[j].size()) ans=std::min(ans,now+g[j].front()-k);
if(g[b[i]-'a'].empty()){t1=0;break;}
for(int j=0;j<26;++j) for(;g[j].size()&&g[j].front()<g[b[i]-'a'].front();++now,++k) g[j].pop();
g[b[i]-'a'].pop();
}
for(int i=0;i<26;++i) for(;g[i].size();++now) g[i].pop();
ans=std::min(ans,now+t1);
}
return 0;
}//第一百十九回 中乡魁宝玉却尘缘 沐皇恩贾家延世泽
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3560kb
input:
pqsrpspqz pqrpqz
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements