# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
928924 | Ghulam_Junaid | Necklace (Subtask 1-3) (BOI19_necklace1) | C++17 | 1542 ms | 432 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;
int main(){
int n, m;
string s, t;
cin >> s >> t;
n = s.size();
m = t.size();
int len = 0;
pair<int, int> mp[3005];
for (int i = 0; i < n; i ++){
string tmp;
for (int j = i; j < n; j ++){
tmp += s[j];
int sz = tmp.size();
for (int k = 0; k < sz; k ++){
string x;
for (int l = k; l < k + sz; l ++)
x += tmp[l % sz];
if (t.find(x) != string::npos and len < sz){
len = sz;
mp[len] = {i, t.find(x)};
}
}
}
}
reverse(s.begin(), s.end());
for (int i = 0; i < n; i ++){
string tmp;
for (int j = i; j < n; j ++){
tmp += s[j];
int sz = tmp.size();
for (int k = 0; k < sz; k ++){
string x;
for (int l = k; l < k + sz; l ++)
x += tmp[l % sz];
if (t.find(x) != string::npos and len < sz){
len = sz;
mp[len] = { n - (i + len - 1) - 1, t.find(x)};
}
}
}
}
cout << len << endl;
cout << mp[len].first << " " << mp[len].second << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |