This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> bool cmin(T &i, T j) { return i > j ? i=j,true:false; }
template<class T> bool cmax(T &i, T j) { return i < j ? i=j,true:false; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
string s,t;
cin >> s >> t;
int n = (int)s.size();
int ans = 0;
int a = 0,b = 0;
auto search = [&](bool sw) {
for (int i=0;i<n;i++) {
for (int j=i;j<n;j++) {
for (int k=i;k>=0;k--) {
string r = s.substr(i,j-i+1);
string f = s.substr(k,i-k);
r += f;
auto z = t.find(r);
if (z != string::npos && cmax(ans,(int)r.size())) {
/*
cout << "s = " << s << endl;
cout << "t = " << t << endl;
cout << "r = " << r << endl;
cout << "find = " << t.find(r) << endl;
*/
a = k;
b = (sw ? n - (z + (int)r.size() - 1) : z);
}
}
}
}
};
search(false);
reverse(t.begin(),t.end());
search(true);
assert(ans);
cout << ans << endl << a << " " << b << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |