# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30094 | 2017-07-22T05:55:49 Z | 김동현(#1246) | Tree Rotations (POI11_rot) | C++14 | 1000 ms | 21776 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, a[400010], c = 1, lc[400010], rc[400010]; ll ans; vector<int> f(int r){ if(a[c]){ vector<int> ret; ret.push_back(a[c]); return ret; } vector<int> lv = f(++c); vector<int> rv = f(++c); vector<int> ret; ll li = 0, ri = 0; for(int i = 0, j = 0; i < lv.size() || j < rv.size(); ){ if(i == lv.size()){ li += int(rv.size()); ret.push_back(rv[j++]); } else if(j == rv.size()){ ri += int(rv.size()); ret.push_back(lv[i++]); } else{ if(lv[i] < rv[j]){ ri += j; ret.push_back(lv[i++]); } else{ li += i; ret.push_back(rv[j++]); } } } ans += min(li, ri); return ret; } int main(){ scanf("%d", &n); for(int i = 1; i < 2 * n; i++) scanf("%d", a + i); f(1); printf("%lld\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 6708 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 6708 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 6708 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 7244 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 239 ms | 8844 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 66 ms | 7460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 21776 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 609 ms | 9100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 15268 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 10032 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 9520 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |