QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246513#4666. Delete And Wincxm1024WA 1ms3396kbC++14731b2023-11-10 21:31:572023-11-10 21:31:59

Judging History

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

  • [2023-11-10 21:31:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3396kb
  • [2023-11-10 21:31:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
string s, t;
int nxt[100010][26];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> s >> t;
	int n = s.size(), m = t.size();
	s = " " + s, t = " " + t;
	for (int i = 0; i < 26; i++)
		nxt[m + 1][i] = m + 1;
	for (int i = m; i >= 1; i--) {
		memcpy(nxt[i], nxt[i + 1], sizeof(nxt[i]));
		nxt[i][t[i] - 'a'] = i;
	}
	int now = 1, ans = 1e9;
	for (int i = 1; i <= n; i++) {
		ans = min(ans, m - (i - 1));
		for (int j = 0; j < s[i] - 'a'; j++) {
			if (nxt[now][j] > m) continue;
			ans = min(ans, nxt[now][j] - i);
		}
		if (nxt[now][s[i] - 'a'] > m) break;
		now = nxt[now][s[i] - 'a'] + 1;
	}
	cout << ans << endl;
	return 0;
}

详细

Test #1:

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

input:

pqsrpspqz
pqrpqz

output:

0

result:

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