알고리즘 문제 시켜봣는데


존나 열심히 코드짬 커여워 ㅋㅋ


We have a tree of N vertices (a connected graph with no undirected cycles). Vertices are numbered 1 through N, and edges are numbered 1 through N-1. Write a program that performs the two queries below. 1 i c: Change the cost of edge i to c. 2 u v: Outputs the largest cost among the simple paths from u to v.

Here is a possible solution using a data structure called a Fenwick tree, also known as a binary indexed tree, to perform the two queries efficiently:


37a79e36ebd518986abce89542877769a8