# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64553 | zetapi | Swap (BOI16_swap) | C++14 | 307 ms | 25596 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;
#define pb push_back
#define mp make_pair
#define int long long
#define itr ::iterator
typedef pair<int,int> pii;
const int MAX=1e6;
int N,n,arr[MAX],p[MAX];
map<pii,int> dp;
map<pii,int> bes;
int get(int ind, int y) {
if (bes.count({ind,y})) return bes[{ind,y}];
if (2*ind > n) return ind;
if (2*ind+1 > n) {
if (y > p[2*ind]) return 2*ind;
return ind;
}
if (y < min(p[2*ind],p[2*ind+1])) return bes[{ind,y}] = ind;
if (p[2*ind] < min(y,p[2*ind+1])) return bes[{ind,y}] = get(2*ind,y);
int mn = min(y,p[2*ind]);
if (get(2*ind,mn) < get(2*ind+1,mn)) {
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... |