当前位置:网站首页>SDNUOJ1015
SDNUOJ1015
2022-07-03 17:48:00 【Codiplay】
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 210;
int d[N];
int e[N], ne[N], h[N];
int idx;
void add(int a, int b)
{
e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}
int ans = -1;
void dfs(int u, int w)
{
ans = max(ans, w);
for (int i = h[u]; ~i; i = ne[i])
{
int j = e[i];
dfs(j, d[j] + w);
}
}
int main(){
//std::ios::sync_with_stdio(false);
//std::cin.tie(nullptr);
memset(h, -1, sizeof h);
int n;
cin >> n;
for (int i = 0; i < n; i ++ ) {
int l, r;
cin >> d[i + 1];
cin >> l >> r;
add(i + 1, l);
add(i + 1, r);
}
dfs(1, 0);
cout << ans << '\n';
return 0;
}
边栏推荐
- [mathematical logic] equivalent calculus and reasoning calculus of predicate logic (individual word | predicate | quantifier | predicate logic formula | two basic formulas | proposition symbolization
- How to install PHP on Ubuntu 20.04
- As soon as we enter "remote", we will never regret, and several people will be happy and several people will be sad| Community essay solicitation
- 鸿蒙第三次培训
- When absolutely positioned, the element is horizontally and vertically centered
- SSL / bio pour OpenSSL Get FD
- ES6类的继承
- Talk about the design and implementation logic of payment process
- [combinatorics] recursive equation (solution of linear non-homogeneous recursive equation with constant coefficients | standard form and general solution of recursive equation | proof of general solut
- SQL injection database operation foundation
猜你喜欢
Hongmeng third training
鸿蒙第四次培训
问题随记 —— 在 edge 上看视频会绿屏
1164 Good in C
How to read the source code [debug and observe the source code]
MySQL grouping query
vs2013已阻止安装程序,需安装IE10
Introduction to SolidWorks gear design software tool geartrax
Records of long objects and long judgments in the stream of list
Talk about the design and implementation logic of payment process
随机推荐
How to deploy applications on kubernetes cluster
supervisor监控Gearman任务
Leetcode 669 pruning binary search tree -- recursive method and iterative method
[combinatorics] recursive equation (special solution form | special solution solving method | special solution example)
Mathematical formula (test)
Where is the monitoring page of RDS database?
Talk about the design and implementation logic of payment process
How to read the source code [debug and observe the source code]
[combinatorics] recursive equation (solution of linear non-homogeneous recursive equation with constant coefficients | standard form and general solution of recursive equation | proof of general solut
Qt调节Win屏幕亮度和声音大小
Leetcode Valentine's Day Special - looking for a single dog
Kotlin's collaboration: Context
When absolutely positioned, the element is horizontally and vertically centered
Graduation summary
Deops入门
[combinatorics] generating function (linear property | product property)
[set theory] order relation: summary (partial order relation | partial order set | comparable | strictly less than | covering | hasto | total order relation | quasi order relation | partial order rela
Cloud primordial weekly | CNCF released the 2021 cloud primordial development status report, which was released on istio 1.13
BFS - topology sort
Applet with multiple tabs and Swipers + paging of each tab