# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44718 | cheater2k | Swap (BOI16_swap) | C++14 | 127 ms | 35288 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;
const int N = 200005;
const int MAX = 1500005;
const int INF = 1e9;
typedef pair<int, int> ii;
int n, a[N], id;
int at[MAX];
int best[MAX];
map <int, int> mp[N];
int dp(int v, int val) {
if (val == INF) return v; // empty vector
if (mp[v].find(val) != mp[v].end()) {
return at[mp[v][val]];
}
mp[v][val] = ++id;
int curid = id;
int l = (v * 2 <= n) ? a[v * 2] : INF;
int r = (v * 2 + 1 <= n) ? a[v * 2 + 1] : INF;
int w[3] = {val, l, r};
if (w[0] < min(w[1], w[2])) {
dp(v << 1, w[1]);
dp(v << 1 | 1, w[2]);
return at[curid] = v;
Compilation message (stderr)
# | 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... |