#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
int main(void){
string a,b;
cin>>a>>b;
ll ans = 0;
for(ll len = min(a.size(),b.size());len >= 1;len--){
map<string,ll>mp;
f(i,0,a.size()-len+1){
string k = a.substr(i,len);
f(j,0,len){
char c = k.back();
k.pop_back();
k = c + k;
mp[k] = i;
}
reverse(all(k));
f(j,0,len){
char c = k.back();
k.pop_back();
k = c + k;
mp[k] = i;
}
}
f(j,0,b.size()-len+1){
string s = b.substr(j,len);
if(mp.count(s)){
cout<<len<<"\n";
cout<<mp[s]<<" "<<j<<"\n";
return 0;
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |