QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#246078 | #4666. Delete And Win | Sham_Devour | WA | 0ms | 3880kb | C++14 | 776b | 2023-11-10 16:05:05 | 2023-11-10 16:05:05 |
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--;
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'