# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896894 | classic | Necklace (Subtask 4) (BOI19_necklace4) | C++14 | 292 ms | 828 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>
namespace classic {
// Knuth-Morris-Pratt
std::vector<int> prefixFunction(std::string str) {
int lengthStr = (int)str.size();
std::vector<int> prefix(lengthStr);
for (int index = 1; index < lengthStr; index++) {
int previousIndex = prefix[index - 1];
while (previousIndex > 0 && str[index] != str[previousIndex]) {
previousIndex = prefix[previousIndex - 1];
}
if (str[index] == str[previousIndex]) {
previousIndex++;
}
prefix[index] = previousIndex;
}
return prefix;
}
} // namespace classic
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::string str1, str2;
std::cin >> str1 >> str2;
int lengthStr1 = str1.size(), lengthStr2 = str2.size();
int maxLength = 0;
std::pair<int, int> positionPrefix;
std::function<void(bool)> turnedOver = [&](bool isTurnedOver) {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |