当前位置:网站首页>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;
}边栏推荐
- 1164 Good in C
- Kotlin's collaboration: Context
- Gear2021 monthly update - December
- Brief introduction to the core functions of automatic penetration testing tool
- QT adjust win screen brightness and sound size
- Detailed explanation of common network attacks
- [combinatorics] recursive equation (special solution example 1 Hannover tower complete solution process | special solution example 2 special solution processing when the characteristic root is 1)
- ArrayList analysis 3: delete elements
- 分布式的任务分发框架-Gearman
- 基于人脸识别的课堂考勤系统 tkinter+openpyxl+face_recognition
猜你喜欢

Research on Swift

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

Ml (machine learning) softmax function to realize the classification of simple movie categories
![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]

Interviewer: why is the value nil not equal to nil?

TensorBoard快速入门(Pytorch使用TensorBoard)
![[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](/img/f1/c96c4a6d34e1ae971f492f4aed5a93.jpg)
[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

1164 Good in C

How to install PHP on Ubuntu 20.04

BFS - topology sort
随机推荐
Servlet specification Part II
PHP returns 500 errors but no error log - PHP return 500 error but no error log
Remote office tools sharing | community essay solicitation
国内如何购买Google Colab会员
Kotlin的协程:上下文
Hongmeng fourth training
Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code
QT learning diary 9 - dialog box
Analysis report on production and marketing demand and investment forecast of China's PVC industry from 2021 to 2026
[combinatorics] generating function (summation property)
PHP MySQL inserts data
Leetcode Valentine's Day Special - looking for a single dog
Vs2013 has blocked the installer, and ie10 needs to be installed
Embedded-c language-7
Type conversion, variable
supervisor监控Gearman任务
(8) HS corner detection
Interviewer: why is the value nil not equal to nil?
Mathematical formula (test)
Keepalived 设置不抢占资源