QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#246912#4666. Delete And WinBINYUWA 0ms3732kbC++14628b2023-11-11 11:58:502023-11-11 11:58:50

Judging History

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

  • [2023-11-11 11:58:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3732kb
  • [2023-11-11 11:58:50]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,cnt,ans = 1e9,head[35],nxt[100005][35];
string s,t;
int main()
{
	cin>>s>>t;
	n = s.size();m = t.size();
	for(int i = m - 1;~i;i--)
	{
		for(int j = t[i] - 'a' + 1;j < 26;j++)head[j] = i;
		for(int j = 0;j < 26;j++)nxt[i][j] = head[j];
	}
	for(int i = 0,now = 0;i < n;i++)
	{
		while(now < m&&t[now] > s[i])now++,cnt++;
		if(t[now] < s[i]||now == m)
			return printf("%d",min(ans,cnt)),0;
		if(nxt[now][s[i] - 'a'])
			ans = min(ans,cnt + nxt[now][s[i] - 'a'] - now);
		now++;
		if(i == n - 1)
			return printf("%d",min(ans,cnt + m - now + 1)),0;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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