QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#245909 | #4666. Delete And Win | Selnev | WA | 1ms | 3596kb | C++14 | 664b | 2023-11-10 14:34:32 | 2023-11-10 14:34:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n, m, ans = 0x3f3f3f3f;
char s[100003], t[100003];
set<int> st[27];
int main() {
scanf("%s%s", s + 1, t + 1);
n = strlen(s + 1);
m = strlen(t + 1);
while (n < m) s[++ n] = '`';
while (n > m) t[++ m] = '`';
for (int i = 1; i <= m; ++ i) st[t[i] - '`'].insert(i);
st[0].insert(m + 1);
for (int i = 1, j = 1; i <= n; ++ i) {
for (int k = 0; k < s[i] - '`'; ++ k) {
const auto it = st[k].lower_bound(j);
if (it != st[k].end()) ans = min(ans, (*it) - i);
}
while (j <= m && t[j] != s[i]) ++ j;
if (j <= m) ++ j;
else break;
}
printf("%d", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3596kb
input:
pqsrpspqz pqrpqz
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'