# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31788 | Diuven | Dreaming (IOI13_dreaming) | C++11 | 205 ms | 15964 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 "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
typedef struct {int to, cost;} edge;
vector<edge> G[100010], T(100010);
vector<int> rad;
bool done[100010];
int N, M, L, tmp, sz[100010], u, D;
int find(int v, bool trace=false, int p=-1, int d=0){
done[v]=true;
if(tmp<d) tmp=d, u=v;
int mx=0;
for(auto& e:G[v]){
if(e.to==p) continue;
int down=find(e.to, false, v, d+e.cost)+e.cost;
if(down>mx) mx=down, T[v]=e;
}
return mx;
}
int findcen(int v){
tmp=-1, find(v); int a=u;
tmp=-1, T.clear(), find(a,true); int b=u, dia=tmp, now=0;
while(a!=b){
int nxt=now+T[a].cost;
if(nxt<=dia-nxt){
a=T[a].to, now=nxt; continue;
}
if(max(now, dia-now)>max(nxt, dia-nxt))
a=T[a].to;
break;
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |