#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int inf = int(1e18);
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> p2;
#define rep(i, high) for (int i = 0; i < high; i++)
#define repp(i, low, high) for (int i = low; i < high; i++)
#define repe(i, container) for (auto& i : container)
#define sz(container) ((int)container.size())
#define all(x) begin(x),end(x)
inline void fast() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#if _LOCAL
#define assert(x) if (!(x)) __debugbreak()
#endif
pair<int,p2> best(string a, string b, bool rev)
{
int ret = -1;
p2 r = p2(-1, -1);
rep(starta, sz(a))
{
rep(startb, sz(b))
{
int rp = 0;
int ra = starta;
int rb = startb;
while (ra<sz(a)&&rb<sz(b)&&a[ra]==b[rb])
{
ra++;
rp++;
rb++;
}
if (rp>ret)
{
r = { starta,startb };
if (rev) r.second = sz(b) - r.second;
ret = rp;
}
}
}
return { ret, r };
}
signed main()
{
fast();
string a, b;
cin >> a >> b;
pair<int, p2> ans = { -1000,p2(0,0) };
ans = max(ans, best(a, b, 0));
reverse(all(b));
ans = max(ans, best(a, b, 1));
cout << ans.first << "\n" << ans.second.first << " " << ans.second.second;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |