QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#700728#4666. Delete And WinCure_BeautyWA 0ms3560kbC++14966b2024-11-02 13:20:172024-11-02 13:20:53

Judging History

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

  • [2024-11-02 13:20:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3560kb
  • [2024-11-02 13:20:17]
  • 提交

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;
}//第一百十九回 中乡魁宝玉却尘缘 沐皇恩贾家延世泽

詳細信息

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