| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 6 초 (추가 시간 없음) | 1024 MB | 4 | 1 | 1 | 25.000% |
In an unenchanted forest there is a mundane rabbit that steals from your garden and you end up chasing after it. The rabbit constantly moves its burrow, so knowing your options for catching the bugger is not easy. The forest is a collection of clearings joined by trails, each trail connecting exactly two clearings. You know, when you chase the rabbit, where it starts and ends its journey. You are solely interested in knowing clearing(s) you can set up a snare to ensure that you trap the rabbit. Note that setting up a snare in rabbit’s starting or ending clearings will definitely catch the rabbit. (We trust that you don’t plan on injuring the rabbit, only taking back your vegetables.)
It will always be the case that the rabbit can reach any clearing from any other clearing, i.e., the rabbit can travel from any clearing to any other clearing.
Given the description of the forest, determine the number of possible clearings where you are guaranteed to be able to trap the rabbit.
The first input line contains two integers: C (1 ≤ C ≤ 105), representing the number of clearings, and T (C-1 ≤ T ≤ 2×105, representing the number of trails.
Each of the following T input lines contains two integers a and b (1 ≤ a, b ≤ C; a ≠ b), representing that clearings a and b are connected by a trail. No pair of clearings are connected directly by more than one trail.
After the initial information for all the clearings, the input will have a set of transactions (operations) to be processed. This section of the input starts with an integer, t (1 ≤ t ≤ 105), indicating the number of transactions. Each of the next t input lines contains a transaction to be processed with the following format:
For each Trap transaction, print the number of locations that you can place a trap to guarantee the bunny will be caught as it travels from its starting clearing to the ending clearing.
9 10 1 2 1 3 2 4 3 4 3 5 3 6 5 6 4 7 7 8 7 9 10 1 2 8 6 1 9 9 8 4 2 6 4 1 6 9 7 4 5 3 4
2 5 4 3 2 3 3 2 3 2
4 4 1 2 2 3 3 4 4 2 3 1 2 1 4 2 3
2 3 2