# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
416006 | nicolaalexandra | Village (BOI20_village) | C++14 | 151 ms | 20420 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>
#define DIM 100010
#define INF 2000000000
using namespace std;
vector <int> L[DIM],w[DIM];
int v[DIM],fth[DIM],sp[DIM],f[DIM],viz[DIM];
pair <int,int> d[DIM];
int n,i,x,y,sol_min,k,idx,poz;
long long sol_max;
void dfs (int nod, int tata){
fth[nod] = tata;
sp[nod] = 1;
for (auto vecin : L[nod])
if (vecin != tata){
dfs (vecin,nod);
sp[nod] += sp[vecin];
}
if (nod != 1 && v[nod] == nod){
sol_min += 2;
swap (v[nod],v[fth[nod]]);
}
sol_max += 2 * min (sp[nod],n-sp[nod]);
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... |