QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#246912 | #4666. Delete And Win | BINYU | WA | 0ms | 3732kb | C++14 | 628b | 2023-11-11 11:58:50 | 2023-11-11 11:58:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt,ans = 1e9,head[35],nxt[100005][35];
string s,t;
int main()
{
cin>>s>>t;
n = s.size();m = t.size();
for(int i = m - 1;~i;i--)
{
for(int j = t[i] - 'a' + 1;j < 26;j++)head[j] = i;
for(int j = 0;j < 26;j++)nxt[i][j] = head[j];
}
for(int i = 0,now = 0;i < n;i++)
{
while(now < m&&t[now] > s[i])now++,cnt++;
if(t[now] < s[i]||now == m)
return printf("%d",min(ans,cnt)),0;
if(nxt[now][s[i] - 'a'])
ans = min(ans,cnt + nxt[now][s[i] - 'a'] - now);
now++;
if(i == n - 1)
return printf("%d",min(ans,cnt + m - now + 1)),0;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3732kb
input:
pqsrpspqz pqrpqz
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'