QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#786009#4666. Delete And Winucup-team266#WA 3ms9264kbC++231.4kb2024-11-26 19:54:452024-11-26 19:55:27

Judging History

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

  • [2024-11-26 19:55:27]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:9264kb
  • [2024-11-26 19:54:45]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int match[100100];
int nxt[100100][26];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin>>s>>t;
	int p=0;
	for(int i=0;i<sz(t);i++)
	{
		while(p<sz(s)&&s[p]!=t[i])
			p++;
		match[i+1]=p;
		if(p!=sz(s)) p++;
	}
	int n=sz(s);
	for(int i=0;i<26;i++)
		nxt[n][i]=n;
	for(int i=n-1;i>=0;i--)
		for(int j=0;j<26;j++)
			nxt[i][j]=(s[i]==j+'a')?i:nxt[i+1][j];
	int ans=0;
	for(int i=0;i<=sz(t);i++)
	{
		int p=match[i];
		if(p>=n) continue;
		if(i!=sz(t))
			ans=max(ans,i);
		if(i<sz(t))
			for(int j=0;j<(t[i]-'a');j++) if(nxt[min(n,p+1)][j]!=n||i!=sz(t))
				ans=max(ans,i+n-nxt[min(n,p+1)][j]);
	}
	cout<<n-ans<<'\n';
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5576kb

input:

pqsrpspqz
pqrpqz

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 9264kb

input:

dbgaifphufyoiulauzhjxjzdthwmutqasyeptbzfmoarvvhvwiykeevdysxiktbpaverxfaepvhdzxudjfzpyqcmdmcbuuitvpmmgsojxdafsihpdzkooiveaugnvzqzcvgvedgpwwcdmbpiiqvjwmhsibyupaghqxshjqlrsbnnnwugbjyxabhvixqkzblduvviuhaseorvwdbhyoyhkzqvtehjlsuynzkwwjofehqcbypelelxmnzwdcbfwfiumbizqxyxbisokciiazerartyyoqjccmlkiexwxnzauep...

output:

1

result:

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