QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#246513 | #4666. Delete And Win | cxm1024 | WA | 1ms | 3396kb | C++14 | 731b | 2023-11-10 21:31:57 | 2023-11-10 21:31:59 |
Judging History
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'