# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
621475 | brobat | Necklace (Subtask 1-3) (BOI19_necklace1) | C++17 | 210 ms | 35764 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;
vector <int> kmp(string &a, string &b) {
string s = b + '#' + a;
int n = s.length();
vector <int> p(n);
p[0] = 0;
for(int i = 1; i < n; i++) {
int j = p[i - 1];
while(j > 0 && s[i] != s[j]) {
j = p[j - 1];
}
if(s[i] == s[j]) {
j++;
}
p[i] = j;
}
vector <int> q(a.length());
for(int i = 0; i < (int)a.length(); i++) {
q[i] = p[i + (int)b.length() + 1];
}
return q;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string a, b;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |