QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#246518 | #4666. Delete And Win | atgc | WA | 1ms | 3416kb | C++14 | 910b | 2023-11-10 21:37:54 | 2023-11-10 21:37:55 |
Judging History
answer
/*YYC is Thinking Here*/
#include<bits/stdc++.h>
#define mids(l,r) const auto mid = (l + r) >> 1
#define lb(x) (x&-x)
#define ls (x<<1)
#define rs (ls|1)
#define int long long
#define pii pair<int,int>
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
const int maxn = 2e5+10;
char s[maxn],t[maxn];
int n,m;
int nxt[maxn][26];
int ans = 0;
signed main() {
ios::sync_with_stdio(0),cin.tie(0);
cin>>(s+1)>>(t+1);
n = strlen(s+1), m = strlen(t+1);
for(int i = 0;i < 26;++i) nxt[m+1][i] = m+1;
for(int i = m;i;--i) {
memcpy(nxt[i],nxt[i+1],sizeof nxt[0]);
nxt[i][t[i]-'a'] = i;
}
int p = 1;
for(int i = 1;i <= n;++i) {
int g = m+1;
for(int c = 0;c < s[i]-'a';++c) g = min(g,nxt[p][c]);
// deb(p,i,g);
ans = max(ans,i + m - g);
p = nxt[p][s[i]-'a']+1;
if(p >= m+1) break;
}
cout<< m - ans;
}
/*
* I love it all
* Go forward,move forward !
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3416kb
input:
pqsrpspqz pqrpqz
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'