| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 826473 | QwertyPi | Necklace (Subtask 1-3) (BOI19_necklace1) | C++14 | 1577 ms | 212 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>
#define int long long
using namespace std;
struct answer{
int a, x, y;
};
bool are_equal(const string& s, const string& t){
if(s.length() != t.length()) return false;
for(int i = 0; i < s.length(); i++){
bool eq = true;
for(int j = 0; j < s.length(); j++){
eq &= s[j] == t[(i + j) % s.length()];
}
if(eq) return true;
}
return false;
}
answer query(const string& s, const string& t){
int n = s.size(), m = t.size();
answer ans {-1, 0, 0};
for(int l = 1; l <= min(n, m); l++){
for(int i = 0; i <= n - l; i++){
for(int j = 0; j <= m - l; j++){
bool ok = are_equal(s.substr(i, l), t.substr(j, l));
if(ok){
ans = answer {l, i, j};
}
}
}
}
return ans;
}
int32_t main(){
string s, t; cin >> s >> t;
answer a1 = query(s, t);
reverse(t.begin(), t.end());
answer a2 = query(s, t); a2.y = t.size() - (a2.y + a2.a);
answer ans; ans.a = -1;
if(a1.a > ans.a) ans = a1;
if(a2.a > ans.a) ans = a2;
cout << ans.a << endl;
cout << ans.x << ' ' << ans.y << 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... | ||||
