# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
996658 | 2024-06-11T03:56:18 Z | berWoW | Tree Rotations (POI11_rot) | C++14 | 286 ms | 65536 KB |
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // namespace __gnu_pbds #include <ext/pb_ds/tree_policy.hpp> using namespace std; typedef __gnu_pbds::tree< int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set; #define MAX_N 212345 int n, cnt; int inv[MAX_N]; ordered_set trunks[MAX_N]; //void read_trunk(int u) { // int p; // scanf("%d", &p); // // if (p != 0) { trunks[u].insert(p); return; } // // read_trunk(2 * u), read_trunk(2 * u + 1); //} int count_inv() { int p; scanf("%d", &p); if (p != 0) { trunks[p].insert(p); return p; } int l = count_inv(), r = count_inv(); if (trunks[l].size() < trunks[r].size()) trunks[l].swap(trunks[r]); int inv_l_r = 0, inv_r_l = 0, i = 0; for (auto it = trunks[r].begin(); it != trunks[r].end(); it++) { trunks[l].insert(*it); int pos = trunks[l].order_of_key(*it); inv_l_r += trunks[l].size() - pos - 1; inv_r_l += pos - i++; } inv[l] = inv[l] + inv[r] + min(inv_l_r, inv_r_l); return l; } int main() { scanf("%d", &n); //read_trunk(1); printf("%d\n", inv[count_inv()]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 16988 KB | Output is correct |
2 | Correct | 13 ms | 16988 KB | Output is correct |
3 | Correct | 9 ms | 16984 KB | Output is correct |
4 | Correct | 12 ms | 16972 KB | Output is correct |
5 | Correct | 9 ms | 16988 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 16988 KB | Output is correct |
2 | Correct | 9 ms | 17056 KB | Output is correct |
3 | Correct | 9 ms | 16988 KB | Output is correct |
4 | Correct | 9 ms | 16988 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 16984 KB | Output is correct |
2 | Correct | 10 ms | 17008 KB | Output is correct |
3 | Correct | 10 ms | 17244 KB | Output is correct |
4 | Correct | 14 ms | 17244 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 17756 KB | Output is correct |
2 | Correct | 14 ms | 17980 KB | Output is correct |
3 | Correct | 11 ms | 17752 KB | Output is correct |
4 | Correct | 12 ms | 17856 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 19292 KB | Output is correct |
2 | Correct | 24 ms | 20396 KB | Output is correct |
3 | Correct | 65 ms | 28244 KB | Output is correct |
4 | Correct | 20 ms | 20156 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 89 ms | 33108 KB | Output is correct |
2 | Correct | 58 ms | 29052 KB | Output is correct |
3 | Correct | 63 ms | 30548 KB | Output is correct |
4 | Correct | 71 ms | 30688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 90 ms | 34268 KB | Output is correct |
2 | Correct | 72 ms | 34696 KB | Output is correct |
3 | Correct | 110 ms | 37200 KB | Output is correct |
4 | Correct | 85 ms | 31992 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 135 ms | 36436 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 169 ms | 65536 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 235 ms | 52444 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 286 ms | 58708 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |