当前位置:网站首页>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;
}边栏推荐
- Ssl/bio of OpenSSL_ get_ fd
- [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
- [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
- Write a program to process a list container of string type. Find a special value in the container 9.27: and delete it if found. Rewrite the above procedure with deque container.
- MySQL grouping query
- [LINUX]CentOS 7 安装MYSQL时报错“No package mysql-server available“No package zabbix-server-mysql availabl
- (8) HS corner detection
- Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code
- PUT vs. POST for Uploading Files - RESTful API to be Built Using Zend Framework
- Micro service component sentinel console call
猜你喜欢

Classroom attendance system based on face recognition tkinter+openpyxl+face_ recognition

Hongmeng fourth training

Draw some simple graphics with MFC

Hongmeng third training

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

Leetcode Valentine's Day Special - looking for a single dog

Global and Chinese health care OEM and ODM market status survey and investment planning recommendations report 2022-2028

STM32实现74HC595控制

聊聊支付流程的设计与实现逻辑

Micro service component sentinel console call
随机推荐
聊聊支付流程的設計與實現邏輯
Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method
Interviewer: why is the value nil not equal to nil?
Applet with multiple tabs and Swipers + paging of each tab
IntelliJ 2021.3 short command line when running applications
A. Berland Poker &1000【简单数学思维】
Analyse ArrayList 3: suppression d'éléments
Micro service component sentinel console call
MySQL has been stopped in the configuration interface during installation
模块九作业
The third day of writing C language by Yabo people
Introduction to PHP MySQL
Enterprise custom form engine solution (XI) -- form rule engine 1
Automata and automatic line of non-standard design
BFS - topology sort
PHP MySQL order by keyword
面试官:值为 nil 为什么不等于 nil ?
The difference between i++ and ++i: tell their differences easily
一入“远程”终不悔,几人欢喜几人愁。| 社区征文
Postfix tips and troubleshooting commands