当前位置:网站首页>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;
}边栏推荐
- 解决Zabbix用snmp监控网络流量不准的问题
- [教程]在 CoreOS 上构建你的第一个应用
- Stm32h7 Hal library SPI DMA transmission has been in busy solution
- 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]
- OpenSSL的SSL/BIO_get_fd
- Global and Chinese pediatric palliative care drug market development research and investment planning recommendations report 2022-2028
- Redis core technology and practice - learning notes (11): why not just string
- How to purchase Google colab members in China
- The difference between i++ and ++i: tell their differences easily
猜你喜欢

1147_ Makefile learning_ Target files and dependent files in makefile

SQL injection database operation foundation

List的stream中Long对象与long判等问题记录

Micro service component sentinel console call
![[combinatorics] generating function (summation property)](/img/74/e6ef8ee69ed07d62df9f213c015f2c.jpg)
[combinatorics] generating function (summation property)

Draw some simple graphics with MFC

AcWing 271. 杨老师的照相排列【多维DP】
![[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](/img/df/a034032e203e7935dafaf8a71cb6c8.jpg)
[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

vs2013已阻止安装程序,需安装IE10

Redis core technology and practice - learning notes (11): why not just string
随机推荐
link preload prefetch
List of financial products in 2022
PHP processing - watermark images (text, etc.)
Research Report on investment trends and development planning of China's thermal insulation material industry, 2022-2028
ArrayList分析3 : 删除元素
Research Report on market demand and investment planning for the development of China's office chair industry, 2022-2028
Remote office tools sharing | community essay solicitation
Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method
互聯網醫院HIS管理平臺源碼,在線問診,預約掛號 智慧醫院小程序源碼
[mathematical logic] equivalent calculus and reasoning calculus of predicate logic (individual word | predicate | quantifier | predicate logic formula | two basic formulas | proposition symbolization
ArrayList分析3 : 删除元素
PHP MySQL inserts multiple pieces of data
Five problems of database operation in commodity supermarket system
Postfix 技巧和故障排除命令
Analysis report on production and marketing demand and investment forecast of China's PVC industry from 2021 to 2026
Inheritance of ES6 class
(8) HS corner detection
Deops入门
模块九作业
QT learning diary 9 - dialog box