# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
353273 | dolphingarlic | Ancient Books (IOI17_books) | C++14 | 369 ms | 127724 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 "books.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int crit_l, crit_r;
int cmp[1000000], cmp_l[1000000], cmp_r[1000000];
map<pair<int, int>, ll> dp;
void extend(int &l, int &r) {
int ext_l = min(cmp_l[cmp[l]], cmp_l[cmp[r]]);
int ext_r = max(cmp_r[cmp[l]], cmp_r[cmp[r]]);
while (l != ext_l || r != ext_r) {
if (l != ext_l) {
l--;
ext_l = min(ext_l, cmp_l[cmp[l]]);
ext_r = max(ext_r, cmp_r[cmp[l]]);
} else {
r++;
ext_l = min(ext_l, cmp_l[cmp[r]]);
ext_r = max(ext_r, cmp_r[cmp[r]]);
}
}
}
ll compute(int l, int r) {
extend(l, r);
if (dp.count({l, r})) return dp[{l, r}];
if (l == crit_l) return dp[{l, r}] = compute(l, r + 1) + 2;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |