# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
928918 | 2024-02-17T08:09:50 Z | Ghulam_Junaid | Necklace (Subtask 1-3) (BOI19_necklace1) | C++17 | 149 ms | 432 KB |
#include <bits/stdc++.h> using namespace std; int main(){ int n, m; string s, t; cin >> s >> t; string r = t; reverse(r.begin(), r.end()); 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]; for (int k = 0; k < j - i + 1; k ++){ string x; for (int l = k; l < k + (j - i + 1); l ++) x += s[l % (j - i + 1)]; if (t.find(x) != string::npos and len < (j - i + 1)){ len = j - i + 1; 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]; for (int k = 0; k < j - i + 1; k ++){ string x; for (int l = k; l < k + (j - i + 1); l ++) x += s[l % (j - i + 1)]; if (t.find(x) != string::npos and len < (j - i + 1)){ len = j - i + 1; mp[len] = { n - (i + len - 1) - 1, t.find(x)}; } } } } cout << len << endl; cout << mp[len].first << " " << mp[len].second << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 149 ms | 432 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 149 ms | 432 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 149 ms | 432 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |