| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 366061 | GusMG | Necklace (Subtask 4) (BOI19_necklace4) | C++17 | 1558 ms | 364 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>=(a);i--)
using ll=long long;
int main(){
    ios_base::sync_with_stdio(0);
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size(),ans=0,l=0,r=0;
    rep(i,0,n) rep(j,i,n) rep(k,j,n) {
        string aux=s.substr(j,k-j)+s.substr(i,j-i);
        int pos=t.find(aux);
        if(pos!=string::npos && aux.size()>ans) ans=aux.size(),l=i,r=pos;
    }
    reverse(s.begin(),s.end());
    rep(i,0,n) rep(j,i,n) rep(k,j,n) {
        string aux=s.substr(j,k-j)+s.substr(i,j-i);
        int pos=t.find(aux);
        if(pos!=string::npos && aux.size()>ans) ans=aux.size(),l=n-k,r=pos;
    }
    cout<<ans<<"\n";
    cout<<l<<" "<<r<<"\n";
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
