QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100

#18804. 树与查询1

الإحصائيات

有一个由 $N$ 个顶点组成的树(无向无环连通图)。顶点从 $1$ 到 $N$ 编号,边从 $1$ 到 $N-1$ 编号。

编写一个程序执行以下两种查询:

  • 1 i c:将第 i 条边的权值改为 c。
  • 2 u v:输出从 u 到 v 的简单路径上权值中的最大值。

输入格式

第一行包含一个整数 $N$ ($2 \le N \le 100{,}000$)。

接下来 $N-1$ 行,每行给出第 i 条边所连接的两个顶点编号 $u$ 和 $v$ 以及权值 $w$。

下一行包含一个整数 $M$ ($1 \le M \le 100{,}000$),表示查询的数量。

接下来 $M$ 行,每行给出一个查询。

边的权值始终是不超过 $1{,}000{,}000$ 的正整数。

输出格式

对于每个类型 2 的查询,按顺序每行输出一个结果。

样例

输入格式 1

3
1 2 1
2 3 2
3
2 1 2
1 1 3
2 1 2

输出格式 1

1
3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.