QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246074#4666. Delete And WinLeasierWA 0ms1616kbC++98826b2023-11-10 16:02:572023-11-10 16:02:58

Judging History

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

  • [2023-11-10 16:02:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1616kb
  • [2023-11-10 16:02:57]
  • 提交

answer

#include <stdio.h>
#include <string.h>

int nxt[100007][27];
char s[100007], t[100007];

inline int min(int a, int b){
	return a < b ? a : b;
}

int main(){
	int n, m, ans = 0x7fffffff;
	scanf("%s %s", &s[1], &t[1]);
	n = strlen(&s[1]);
	m = strlen(&t[1]);
	for (int i = 1; i <= 26; i++){
		nxt[m + 1][i] = m + 1;
	}
	for (int i = m; i >= 1; i--){
		for (int j = 1; j <= 26; j++){
			nxt[i][j] = nxt[i + 1][j];
		}
		nxt[i][t[i] - 'a' + 1] = i;
	}
	for (int i = 0, j = 0; i < n; i++, j++){
		if (i > 0){
			while (j <= m && t[j] != s[i]) j++;
			if (j > m) break;
		}
		int cur_ans = m - j;
		for (int k = 1; k < s[i + 1] - 'a' + 1; k++){
			if (nxt[j + 1][k] <= m) cur_ans = min(cur_ans, nxt[j + 1][k] - j - 1);
		}
		ans = min(ans, (j - i) + cur_ans);
	}
	printf("%d", ans);
	return 0;
}

详细

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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