제출 #31646

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
316462017-08-30 08:33:34cheater2kBeads and wires (APIO14_beads)C++14
57 / 100
289 ms24224 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const int inf = 2e9 + 12345;
int n;
int f[N][2], g[N][2];
vector < pair<int,int> > G[N], ch[N];
int ans;
void dfs(int u, int p) {
for (auto edge: G[u]) if (edge.second != p) {
dfs(edge.second, u);
ch[u].push_back(edge);
}
f[u][1] = -inf;
f[u][0] = 0;
for (auto edge: ch[u]) {
f[u][0] += max(f[edge.second][0], f[edge.second][1] + edge.first);
}
for (auto edge: ch[u]) {
int mx = f[u][0];
mx -= max(f[edge.second][0], f[edge.second][1] + edge.first);
mx += (f[edge.second][0] + edge.first);
f[u][1] = max(f[u][1], mx);
}
}
void re_dfs(int u, int p) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...