当前位置:网站首页>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;
}
边栏推荐
- Getting started with deops
- The difference between i++ and ++i: tell their differences easily
- Brief introduction to the core functions of automatic penetration testing tool
- 1147_ Makefile learning_ Target files and dependent files in makefile
- Leetcode 108 converts an ordered array into a binary search tree -- recursive method
- Kubernetes resource object introduction and common commands (4)
- PS screen printing brush 131, many illustrators have followed suit
- TCP拥塞控制详解 | 3. 设计空间
- Embedded-c language-7
- MinGW compile boost library
猜你喜欢
鸿蒙第三次培训
(9) Opencv Canny edge detection
Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method
Notes on problems -- watching videos on edge will make the screen green
QT learning diary 9 - dialog box
Talk about the design and implementation logic of payment process
微服务组件Sentinel控制台调用
Select 3 fcpx plug-ins. Come and see if you like them
Hongmeng fourth training
vs2013已阻止安装程序,需安装IE10
随机推荐
[combinatorics] recursive equation (summary of the solution process of recursive equation | homogeneous | double root | non-homogeneous | characteristic root is 1 | exponential form | the bottom is th
Ml (machine learning) softmax function to realize the classification of simple movie categories
Qt调节Win屏幕亮度和声音大小
How to enforce parameters in PowerShell- How do I make parameters mandatory in PowerShell?
Research Report on investment trends and development planning of China's thermal insulation material industry, 2022-2028
Web-ui automated testing - the most complete element positioning method
[combinatorics] generating function (summation property)
link preload prefetch
TensorBoard快速入门(Pytorch使用TensorBoard)
Implementation of Tetris in C language
PR second time
TCP congestion control details | 3 design space
OpenSSL的SSL/BIO_get_fd
PHP processing - watermark images (text, etc.)
Research Report on competitive strategy Outlook Analysis and investment strategic planning of China's smart home equipment industry, 2022-2028
MySQL grouping query
Remote office tools sharing | community essay solicitation
TCP拥塞控制详解 | 3. 设计空间
How to install PHP on Ubuntu 20.04
[vscode] convert tabs to spaces