# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
36405 | ToMoClone | Ball Machine (BOI13_ballmachine) | C++14 | 299 ms | 22528 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.
/*input
*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int N = 100001;
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > Empty;
vector<int> child[N];
int n, q, cnt, Min[N], par[17][N], Ball[N], Pos[N];
void dfs(int u){
for(int v:child[u])
dfs(v), Min[u] = min(Min[u], Min[v]);
sort(child[u].begin(), child[u].end(), [&](int a, int b){
return Min[a] < Min[b];
});
}
void dfs2(int u){
for(int v:child[u]) dfs2(v);
Empty.push(make_pair(Pos[u] = ++cnt, u));
}
int main(){
scanf("%d%d", &n, &q);
for(int i = 1; i <= n; ++i){
int u; scanf("%d", &u);
child[u].push_back(i);
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... |