当前位置:网站首页>SDNUOJ1015
SDNUOJ1015
2022-07-03 17:53: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;
}
边栏推荐
- PHP returns 500 errors but no error log - PHP return 500 error but no error log
- Global and Chinese health care OEM and ODM market status survey and investment planning recommendations report 2022-2028
- c# .net 工具生态
- Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method
- Leetcode 669 pruning binary search tree -- recursive method and iterative method
- AcWing 3438. 数制转换
- Life perception 1
- What is the difference between cloud server and cloud virtual machine
- Research on Swift
- Redis core technology and practice - learning notes (11): why not just string
猜你喜欢
Hongmeng third training
微服务组件Sentinel控制台调用
STM32实现74HC595控制
(8) HS corner detection
Global and Chinese health care OEM and ODM market status survey and investment planning recommendations report 2022-2028
面试官:值为 nil 为什么不等于 nil ?
Global and Chinese pediatric palliative care drug market development research and investment planning recommendations report 2022-2028
Getting started with deops
Market demand survey and marketing strategy analysis report of global and Chinese pet milk substitutes 2022-2028
vs2013已阻止安装程序,需安装IE10
随机推荐
PHP returns 500 errors but no error log - PHP return 500 error but no error log
OpenSSL的SSL/BIO_get_fd
Deops入门
Wechat applet for the first time
Managing multiple selections with MVVM - managing multiple selections with MVVM
模块九作业
Remote office tools sharing | community essay solicitation
Implementation of Tetris in C language
Redis core technology and practice - learning notes (11): why not just string
[combinatorics] generating function (summation property)
How to deploy applications on kubernetes cluster
c# .net 工具生态
Global and Chinese pediatric palliative care drug market development research and investment planning recommendations report 2022-2028
BFS - topology sort
What is the difference between cloud server and cloud virtual machine
一入“远程”终不悔,几人欢喜几人愁。| 社区征文
Ml (machine learning) softmax function to realize the classification of simple movie categories
ArrayList analysis 3: delete elements
Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method
Redis core technology and practice - learning notes (VI) how to achieve data consistency between master and slave Libraries