# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403117 | rama_pang | Necklace (Subtask 1-3) (BOI19_necklace1) | C++17 | 489 ms | 106460 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() {
ios::sync_with_stdio(0);
cin.tie(0);
string S, T;
cin >> S >> T;
const auto Solve = [&]() -> array<int, 3> {
int N = S.size();
int M = T.size();
array<int, 3> ans = {0, 0, 0};
// lcs[i][j] = longest common suffix of S[0...i], T[0...j]
// dp1[i][j] = longest suffix of S[0...i] which is prefix of T[j...M]
// dp2[i][j] = longest prefix of S[i...N] which is suffix of T[0...j]
vector<vector<int>> lcs(N, vector<int>(M));
vector<vector<int>> dp1(N, vector<int>(M));
vector<vector<int>> dp2(N, vector<int>(M));
for (int s = 0; s < N; s++) {
for (int t = 0; t < M; t++) {
lcs[s][t] = S[s] == T[t] ? ((s > 0 && t > 0 ? lcs[s - 1][t - 1] : 0) + 1) : 0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |