QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246078#4666. Delete And WinSham_DevourWA 0ms3880kbC++14776b2023-11-10 16:05:052023-11-10 16:05:05

Judging History

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

  • [2023-11-10 16:05:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3880kb
  • [2023-11-10 16:05:05]
  • 提交

answer

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
const int N = 1e5 + 5, S = 26;

char s[N], t[N];
int ns, nt, tot, ans, pos[N], lst[S];

int main() {
	scanf("%s %s", s + 1, t + 1), ns = strlen(s + 1), nt = strlen(t + 1);
	ans = nt;
	for (int i = 1, j = 1; i < ns; i++) {
		while (j <= nt && s[i] != t[j]) j++;
		if (j <= nt) pos[++tot] = j++;
		else break;
	}
	for (int i = tot, j = nt; i >= 0; i--) {
		if (pos[i] == nt) {ans = min(ans, pos[i] - i); continue;}
		while (j > pos[i]) lst[t[j] - 'a'] = j, j--;
		ans = min(ans, nt - i);
		int p = 1e9;
		for (int k = 0; k < s[i + 1] - 'a'; k++)
			if (lst[k]) p = min(p, lst[k]);
		if (p == 1e9) continue;
		ans = min(ans, p - i - 1);
	}
	printf("%d", ans);
	return 0;
}

詳細信息

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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