当前位置:网站首页>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;
}边栏推荐
- Kotlin的协程:上下文
- Leetcode540: a single element in an ordered array
- 互聯網醫院HIS管理平臺源碼,在線問診,預約掛號 智慧醫院小程序源碼
- Talk about the design and implementation logic of payment process
- link preload prefetch
- 企业级自定义表单引擎解决方案(十一)--表单规则引擎1
- Introduction to SolidWorks gear design software tool geartrax
- How to install PHP on Ubuntu 20.04
- ArrayList analysis 3: delete elements
- Play with fancy special effects. This AE super kit is for you
猜你喜欢

Draw some simple graphics with MFC

Hongmeng third training

Kubernetes resource object introduction and common commands (III)

Baiwen.com 7 days Internet of things smart home learning experience punch in the next day

Talk about the design and implementation logic of payment process

Applet setting multi account debugging

QT学习日记9——对话框

As soon as we enter "remote", we will never regret, and several people will be happy and several people will be sad| Community essay solicitation

Tensorboard quick start (pytoch uses tensorboard)

PS screen printing brush 131, many illustrators have followed suit
随机推荐
[RT thread] NXP rt10xx device driver framework -- pin construction and use
企业级自定义表单引擎解决方案(十一)--表单规则引擎1
聊聊支付流程的设计与实现逻辑
List的stream中Long对象与long判等问题记录
Interviewer: why is the value nil not equal to nil?
Hongmeng fourth training
[combinatorics] generating function (summation property)
Automata and automatic line of non-standard design
Swm32 series Tutorial 4 port mapping and serial port application
MinGW compile boost library
POM in idea XML graying solution
The gbase 8A database does not support the DB2 function value (column_name, 0) cluster syntax
PHP processing - watermark images (text, etc.)
Kubernetes resource object introduction and common commands (4)
STM32实现74HC595控制
Life perception 1
AcWing 4489. 最长子序列
分布式的任务分发框架-Gearman
WEB-UI自动化测试-最全元素定位方法
Five problems of database operation in commodity supermarket system