제출 #235682

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
2356822020-05-29 11:01:28oolimry구슬과 끈 (APIO14_beads)C++14
0 / 100
7 ms4992 KiB
#include <bits/stdc++.h>
#define norope first
#define v first
#define rope second
#define w second
#define all(x) x.begin(), x.end()
using namespace std;
typedef pair<long long, long long> ii;
const long long inf = 1023456789012345;
vector<ii> adj[200005];
///norope, red edge to parent is normal
///rope, blue edge to parent is normal
///norope, blue edge to parent is normal
///each node can only have <= 2 special edges from children.
///if 1 special, then node is rope. if 0 or 2, then is norope
ii dfs(int u, int p){
vector<long long> specialDifference = {-inf, -inf};
long long sumNormal = 0;
for(ii e : adj[u]){
if(e.v == p) continue;
ii res = dfs(e.v, u);
long long normal = max(e.w + res.rope, res.norope);
long long special = e.w + res.norope;
sumNormal += normal;
specialDifference.push_back(special - normal);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...