QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245878#4666. Delete And WinMYFJCHCWA 0ms3592kbC++14860b2023-11-10 14:19:362023-11-10 14:19:38

Judging History

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

  • [2023-11-10 14:19:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3592kb
  • [2023-11-10 14:19:36]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5, K = 26;

int n, m;
char s[N], t[N];
int nxt[N][K];

int main()
{
//	freopen("string.in", "r", stdin);
//	freopen("string.out", "w", stdout);
	
	scanf("%s%s", s + 1, t + 1);
	n = strlen(s + 1), m = strlen(t + 1);
	
	for(int i = 0; i < K; i ++ ) nxt[m + 1][i] = m + 1;
	for(int i = m; i >= 1; i -- )
	{
		for(int j = 0; j < K; j ++ ) nxt[i][j] = nxt[i + 1][j];
		nxt[i][t[i] - 'a'] = i;
	}
	
	int ans = m;
	for(int i = 1, j = 1, c = 0; i <= n && j <= m; i ++ )
	{
//		printf("!%d %d %d %d\n", i, j, ans, c);
		ans = min(ans, c + m - j + 1);
		for(int k = 0; k < s[i] - 'a'; k ++ ) ans = min(ans, c + nxt[j][k] - j);
		c += nxt[j][s[i] - 'a'] - j;
		j = nxt[j][s[i] - 'a'] + 1;
		if(j > m && i < n) ans = min(ans, c);
	}
	printf("%d\n", ans);
	return 0;
}

详细

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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