QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#246074 | #4666. Delete And Win | Leasier | WA | 0ms | 1616kb | C++98 | 826b | 2023-11-10 16:02:57 | 2023-11-10 16:02:58 |
Judging History
answer
#include <stdio.h>
#include <string.h>
int nxt[100007][27];
char s[100007], t[100007];
inline int min(int a, int b){
return a < b ? a : b;
}
int main(){
int n, m, ans = 0x7fffffff;
scanf("%s %s", &s[1], &t[1]);
n = strlen(&s[1]);
m = strlen(&t[1]);
for (int i = 1; i <= 26; i++){
nxt[m + 1][i] = m + 1;
}
for (int i = m; i >= 1; i--){
for (int j = 1; j <= 26; j++){
nxt[i][j] = nxt[i + 1][j];
}
nxt[i][t[i] - 'a' + 1] = i;
}
for (int i = 0, j = 0; i < n; i++, j++){
if (i > 0){
while (j <= m && t[j] != s[i]) j++;
if (j > m) break;
}
int cur_ans = m - j;
for (int k = 1; k < s[i + 1] - 'a' + 1; k++){
if (nxt[j + 1][k] <= m) cur_ans = min(cur_ans, nxt[j + 1][k] - j - 1);
}
ans = min(ans, (j - i) + cur_ans);
}
printf("%d", ans);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1616kb
input:
pqsrpspqz pqrpqz
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'