Judgement
시간 제한2초메모리 제한1024 MB
가중치가 있는 트리에서 후보가 이웃 y로 이동할 확률이 1/w에 비례할 때, 간선 갱신 후 u에서 v까지의 기대 도달 시간을 1e9+7로 나눈 값으로 출력한다.
문제
You were preparing for the KAIST RUN ICPC 2025 Contest and completely forgot to submit your calculus homework. Now the professor has declared Judgement Day.
He has unleashed the legendary Hubo robot, programmed with only one mission: find you anywhere on campus and gently encourage you to finish the assignment.
The KAIST campus can be modeled as buildings connected by roads, forming a tree. Each road has a road congestion .
When Hubo is at place , it picks its next move randomly. For each neighbor of , the probability that Hubo moves from to is where is the congestion of road and denotes all neighbors of .
Unfortunately for you, the professor can alter the campus roads over time, changing their loads.
You must process events:
1 id new_w— the congestion of the road with indexidbecomesnew_w;2 u v— you are hiding at place , and Hubo is deployed at place . Output the expected number of steps until Hubo reaches you. If , the answer is .
Since the expectation can be rational, output it modulo . Formally, if the expectation equals in lowest terms, print , where is the modular inverse of modulo .
입력
The first line contains two integers and . Each of the next lines contains three integers describing a road between places and with congestion (). Roads are indexed in the order they appear. Each of the following lines is one event in the formats above.
출력
For each query of type , print a single integer — the expected number of steps modulo .
제한
- For every road congestion ,