QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#702190 | #4666. Delete And Win | Milkcat2009 | WA | 0ms | 3592kb | C++14 | 1.1kb | 2024-11-02 15:27:47 | 2024-11-02 15:27:47 |
Judging History
answer
#include <bits/stdc++.h>
#define REP(i, l, r) for (int i = (l); i <= (r); ++ i)
#define DEP(i, r, l) for (int i = (r); i >= (l); -- i)
#define fi first
#define se second
#define pb emplace_back
#define mems(x, v) memset((x), (v), sizeof(x))
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
namespace Milkcat {
typedef long long LL;
typedef pair<LL, LL> pii;
const int N = 1e5 + 5;
int n, m, nx[N][26]; string s, t;
int main() {
cin >> s >> t, n = SZ(s), m = SZ(t), s = "#" + s, t = "#" + t;
REP(i, 0, 25) nx[n][i] = 1e9;
DEP(i, n - 1, 0) {
REP(j, 0, 25) nx[i][j] = nx[i + 1][j];
nx[i][s[i + 1] - 'a'] = i + 1;
}
int p = 0, rs = 0;
REP(i, 0, m - 1) {
if (i > 0) p = nx[p][t[i] - 'a'];
if (p > n) break;
rs = max(rs, i);
REP(j, 0, t[i + 1] - 'a' - 1)
rs = max(rs, i + n - nx[p][j] + 1);
}
cout << n - rs << '\n';
return 0;
}
}
int main() {
// freopen("string.in", "r", stdin);
// freopen("string.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int T = 1; cin >> T;
while (T --) Milkcat::main();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3592kb
input:
pqsrpspqz pqrpqz
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements