# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
987725 | vjudge1 | Ideal city (IOI12_city) | C++17 | 31 ms | 12436 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.
#pragma once
#include "bits/stdc++.h"
#define F first
#define S second
#define ll long long
#define pii pair<ll,ll>
const int mxN = 2e5 + 5;
const int mod = 1e9;
using namespace std;
vector<vector<int>>v;
ll dpD[mxN],dpU[mxN];
ll subD[mxN],subU[mxN];
ll w[mxN];
int p[mxN];
ll ans;
void dfs(int u,int par){
subD[u] = w[u];
p[u] = par;
for(auto x : v[u]){
if(x == par) continue;
dfs(x,u);
dpD[u] += dpD[x] + subD[x] * w[u];
subD[u] += subD[x];
}
}
void hfs(int u,int par){
// subU[u] = w[u];
dpU[u] = dpU[par] + subU[par] * w[u];
subU[u] += subU[par];
if(par){
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... |