当前位置:网站首页>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;
}边栏推荐
- Applet setting multi account debugging
- 聊聊支付流程的设计与实现逻辑
- STM32实现74HC595控制
- Loop through JSON object list
- [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
- c# .net 工具生态
- Research Report on market demand and investment planning for the development of China's office chair industry, 2022-2028
- TensorBoard快速入门(Pytorch使用TensorBoard)
- MySQL has been stopped in the configuration interface during installation
- 远程办公工具分享|社区征文
猜你喜欢

Deops入门

Qt调节Win屏幕亮度和声音大小

Baiwen.com 7 days Internet of things smart home learning experience punch in the next day
![How to read the source code [debug and observe the source code]](/img/40/a2fca67bcde3c468a739c6990325f4.jpg)
How to read the source code [debug and observe the source code]

Analysis report on production and marketing demand and investment forecast of China's PVC industry from 2021 to 2026

Research Report on investment trends and development planning of China's thermal insulation material industry, 2022-2028

Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code

Talk about the design and implementation logic of payment process

Leetcode 669 pruning binary search tree -- recursive method and iterative method

Automata and automatic line of non-standard design
随机推荐
Comparison of kotlin collaboration + retro build network request schemes
[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
Website with JS doesn't work in IE9 until the Developer Tools is activated
[Yu Yue education] family education SPOC class 2 reference materials of Shanghai Normal University
PR second time
(9) Opencv Canny edge detection
Records of long objects and long judgments in the stream of list
Leetcode540: a single element in an ordered array
1146_ SiCp learning notes_ exponentiation
Select 3 fcpx plug-ins. Come and see if you like them
[combinatorics] recursive equation (special solution form | special solution solving method | special solution example)
问题随记 —— 在 edge 上看视频会绿屏
c# .net 工具生态
Loop through JSON object list
Five problems of database operation in commodity supermarket system
[combinatorics] recursive equation (four cases where the non-homogeneous part of a linear non-homogeneous recursive equation with constant coefficients is the general solution of the combination of po
Talk about the design and implementation logic of payment process
[RT thread] construction and use of --hwtimer of NXP rt10xx device driver framework
Fedora 21 安装 LAMP 主机服务器
分布式的任务分发框架-Gearman