当前位置:网站首页>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;
}
边栏推荐
- Automata and automatic line of non-standard design
- Keepalived setting does not preempt resources
- List of financial products in 2022
- Market demand survey and marketing strategy analysis report of global and Chinese pet milk substitutes 2022-2028
- Redis core technology and practice - learning notes (VIII) sentinel cluster: sentinel hung up
- Talk about the design and implementation logic of payment process
- Redis core technology and practice - learning notes (VI) how to achieve data consistency between master and slave Libraries
- Leetcode Valentine's Day Special - looking for a single dog
- TCP congestion control details | 3 design space
- Vs2013 has blocked the installer, and ie10 needs to be installed
猜你喜欢
STM32实现74HC595控制
Internet Hospital his Management Platform source, online Inquiry, appointment Registration Smart Hospital Small program source
Hongmeng fourth training
Research Report on competitive strategy Outlook Analysis and investment strategic planning of China's smart home equipment industry, 2022-2028
一入“远程”终不悔,几人欢喜几人愁。| 社区征文
Leetcode 669 pruning binary search tree -- recursive method and iterative method
1146_ SiCp learning notes_ exponentiation
[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
Redis core technology and practice - learning notes (11): why not just string
Interviewer: why is the value nil not equal to nil?
随机推荐
PHP MySQL create database
Stm32h7 Hal library SPI DMA transmission has been in busy solution
Internet Hospital his Management Platform source, online Inquiry, appointment Registration Smart Hospital Small program source
PHP MySQL inserts multiple pieces of data
How to deploy applications on kubernetes cluster
PR second time
Market demand survey and marketing strategy analysis report of global and Chinese pet milk substitutes 2022-2028
How to install PHP on Ubuntu 20.04
SSL / bio pour OpenSSL Get FD
BFS - topology sort
1147_ Makefile learning_ Target files and dependent files in makefile
Research Report on competitive strategy Outlook Analysis and investment strategic planning of China's smart home equipment industry, 2022-2028
Graduation summary
PHP MySQL preprocessing statement
ArrayList分析3 : 删除元素
面试官:值为 nil 为什么不等于 nil ?
i++与++i的区别:通俗易懂的讲述他们的区别
Type conversion, variable
Interviewer: why is the value nil not equal to nil?
WEB-UI自动化测试-最全元素定位方法