QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245909#4666. Delete And WinSelnevWA 1ms3596kbC++14664b2023-11-10 14:34:322023-11-10 14:34:34

Judging History

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

  • [2023-11-10 14:34:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3596kb
  • [2023-11-10 14:34:32]
  • 提交

answer

#include <bits/stdc++.h>


using namespace std;


int n, m, ans = 0x3f3f3f3f;
char s[100003], t[100003];
set<int> st[27];


int main() {
	scanf("%s%s", s + 1, t + 1);
	n = strlen(s + 1);
	m = strlen(t + 1);
	while (n < m) s[++ n] = '`';
	while (n > m) t[++ m] = '`';
	for (int i = 1; i <= m; ++ i) st[t[i] - '`'].insert(i);
	st[0].insert(m + 1);
	for (int i = 1, j = 1; i <= n; ++ i) {
		for (int k = 0; k < s[i] - '`'; ++ k) {
			const auto it = st[k].lower_bound(j);
			if (it != st[k].end()) ans = min(ans, (*it) - i);
		}
		while (j <= m && t[j] != s[i]) ++ j;
		if (j <= m) ++ j;
		else break;
	}
	printf("%d", ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3596kb

input:

pqsrpspqz
pqrpqz

output:

0

result:

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