Logo
(追記) (追記ここまで)

30234번 - Bad Bunny 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
6 초 (추가 시간 없음) 1024 MB41125.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:

  • Trap Transaction: This input line provides two valid clearings s and d. The bunny is moving from s to d and you need to determine the number of clearings a trap could be placed such that the bunny can be caught. Note that only a single trap must be placed in a single clearing to catch the rabbit, and we are interested in knowing how many such clearings exist. Note also that s and d are two of the answers, i.e., the result will be at least 2.

출력

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.

제한

예제 입력 1

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

예제 출력 1

2
5
4
3
2
3
3
2
3
2

예제 입력 2

4 4
1 2
2 3
3 4
4 2
3
1 2
1 4
2 3

예제 출력 2

2
3
2

힌트

출처

University > University of Central Florida > 2023 Local Programming Contest (Final Round) 11번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /