QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#245878 | #4666. Delete And Win | MYFJCHC | WA | 0ms | 3592kb | C++14 | 860b | 2023-11-10 14:19:36 | 2023-11-10 14:19:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, K = 26;
int n, m;
char s[N], t[N];
int nxt[N][K];
int main()
{
// freopen("string.in", "r", stdin);
// freopen("string.out", "w", stdout);
scanf("%s%s", s + 1, t + 1);
n = strlen(s + 1), m = strlen(t + 1);
for(int i = 0; i < K; i ++ ) nxt[m + 1][i] = m + 1;
for(int i = m; i >= 1; i -- )
{
for(int j = 0; j < K; j ++ ) nxt[i][j] = nxt[i + 1][j];
nxt[i][t[i] - 'a'] = i;
}
int ans = m;
for(int i = 1, j = 1, c = 0; i <= n && j <= m; i ++ )
{
// printf("!%d %d %d %d\n", i, j, ans, c);
ans = min(ans, c + m - j + 1);
for(int k = 0; k < s[i] - 'a'; k ++ ) ans = min(ans, c + nxt[j][k] - j);
c += nxt[j][s[i] - 'a'] - j;
j = nxt[j][s[i] - 'a'] + 1;
if(j > m && i < n) ans = min(ans, c);
}
printf("%d\n", ans);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3592kb
input:
pqsrpspqz pqrpqz
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'