QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#785965 | #4666. Delete And Win | ucup-team266# | WA | 2ms | 8828kb | C++23 | 1.3kb | 2024-11-26 19:44:45 | 2024-11-26 19:44:46 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int match[100100];
int nxt[100100][26];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s,t;
cin>>s>>t;
int p=0;
for(int i=0;i<sz(t);i++)
{
while(p<sz(s)&&s[p]!=t[i])
p++;
match[i+1]=p;
if(p!=sz(s)) p++;
}
int n=sz(s);
for(int i=0;i<26;i++)
nxt[n][i]=n;
for(int i=n-1;i>=0;i--)
for(int j=0;j<26;j++)
nxt[i][j]=(s[i]==j+'a')?i:nxt[i+1][j];
int ans=0;
for(int i=0;i<=sz(t);i++)
{
int p=match[i];
if(p>=n) continue;
ans=max(ans,i);
if(i<sz(t))
for(int j=0;j<(t[i]-'a');j++)
ans=max(ans,i+n-nxt[min(n,p+1)][j]);
}
cout<<n-ans<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3484kb
input:
pqsrpspqz pqrpqz
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 8828kb
input:
dbgaifphufyoiulauzhjxjzdthwmutqasyeptbzfmoarvvhvwiykeevdysxiktbpaverxfaepvhdzxudjfzpyqcmdmcbuuitvpmmgsojxdafsihpdzkooiveaugnvzqzcvgvedgpwwcdmbpiiqvjwmhsibyupaghqxshjqlrsbnnnwugbjyxabhvixqkzblduvviuhaseorvwdbhyoyhkzqvtehjlsuynzkwwjofehqcbypelelxmnzwdcbfwfiumbizqxyxbisokciiazerartyyoqjccmlkiexwxnzauep...
output:
1
result:
wrong answer 1st numbers differ - expected: '0', found: '1'