QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#245921 | #4666. Delete And Win | Sham_Devour | WA | 1ms | 3832kb | C++14 | 749b | 2023-11-10 14:39:34 | 2023-11-10 14:39:36 |
Judging History
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--;
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: 1ms
memory: 3832kb
input:
pqsrpspqz pqrpqz
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'