General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
108350993 Practice:
Dhoni_fan
1492C - 35 C++17 (GCC 7-32) Accepted 62 ms 4068 KB 2021-02-24 05:58:29 2021-02-24 05:58:29
→ Source
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long int

int main(){
    ll n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
    string p = s;
    string q = t;
    reverse(p.begin(),p.end());
    reverse(q.begin(),q.end());
    ll j =0;
    vector<ll> R(m+1,0),le(m+1,0);
    for(ll i = 0;i<m;i++){
        while(j<n){
            if(p[j]==q[i]){
                R[m-i-1] = n-j;
                j++;
                break;
            }
            j++;
        }
    }
    j=0;
    for(ll i = 0;i<m;i++){
        while(j<n){
            if(s[j]==t[i]){
                le[i]=j+1;
                j++;
                break;
            }
            j++;
        }
    }
    ll ans = 0;
    for(ll i = 1;i<m;i++){
        //if(i==0)a = R[i]-1;
        //else if(i==m)a = n-le[i-1];
        ll a = R[i]-le[i-1];
        //cout<<R[i]<<" "<<le[i-1]<<"\n";
        ans = max(ans,a);
    }
    cout<<ans;
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details