12807번 - Bridge testing

시간 제한

메모리 제한

제출

정답

맞은 사람

정답 비율

4 초

256 MB

11

1

1

10.000%

문제

A small island country is developing its transport network. Some of the islands are connected by bridges in such way that there is a unique path between any two islands. In other words, bridges form a tree. Bridges can have different length.

Before opening these bridges to the public it is required to test their safety. To do that, two testers will be traversing some paths with a speed 1 every day for the next q days. Each one will go along his own path, possibly starting at different time. Let's call a bridge tested on i-th day if both testers were going along that bridge during some non-zero time interval. For each of q days determine, if there was a bridge that was tested during that day.