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

28494번 - Network 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB31141453.846%

문제

Rui Yuan the Duck is building a new network to run all of his new applications. This network is comprised of $n$ servers numbered from 1ドル$ to $n$. There are also $n - 1$ network links, numbered from 1ドル$ to $n - 1$ connecting these servers.

The $i$-th of these links connects servers $u[i]$ and $v[i]$ bidirectionally. It is guaranteed that it is possible to travel from any server to any other server using only the servers and network links.

Initially, all $n$ servers are active. Rui Yuan has $m$ applications running, which have distinct IDs from 1ドル$ to $m$. Each application has 2ドル$ databases. Application $j$ has databases in servers $a[j]$ and $b[j]$ (which may be the same server). It is possible for two different applications to have a database on the same server.

In order for application $j$ to work, both of its databases must be connected through network links and active servers. To be precise, application $j$ is working if both of the following conditions are met:

  • Servers $a[j]$ and $b[j]$ are both active.
  • One can travel from server $a[j]$ to server $b[j]$ using only network links and active servers.

Rui Yuan has asked Benson the Rabbit to test his network. Using his hacking skills, Benson can select any set of servers and deactivate all of them simultaneously. The robustness of the network is the minimum number of servers that must be deactivated to ensure all $m$ applications are not working.

Benson is very busy, so he wants you to help him compute the robustness of the network and the selection of servers he should deactivate so that he doesn’t waste time deactivating more servers than needed.

입력

The first line of input contains two integers, $n$ and $m$.

$n - 1$ lines will follow. The $i$-th line contains two integers, $u[i]$ and $v[i]$ respectively, which are the servers connected by the $i$-th network link.

Another $m$ lines will follow. The $j$-th line contains two integers, $a[j]$ and $b[j]$ respectively, which are the servers storing the databases for application $j$.

출력

Output two lines. The first line should contain a single integer, representing the robustness of the network, which we will denote as $x$.

The second line should contain $x$ integers, representing the servers that should be deactivated. All $x$ integers must be pairwise distinct. You may output them in any order.

제한

  • 1ドル ≤ n ≤ 200,000円$
  • 1ドル ≤ m ≤ 200,000円$
  • 1ドル ≤ u[i], v[i] ≤ n,ドル $u[i] \ne v[i]$ (for all 1ドル ≤ i ≤ n$).
  • 1ドル ≤ a[j], b[j] ≤ n$ (for all 1ドル ≤ j ≤ m$)
  • It is possible to travel from any server to any other server using only the servers and network links.

서브태스크

번호배점제한
14

$a[i] = b[i]$

217

$u[i] = i,ドル $v[i] = i + 1$

314

$n, m ≤ 15$

429

$n, m ≤ 2000$

536

No additional restrictions

예제 입력 1

9 4
1 2
2 3
2 6
3 4
4 5
4 7
6 9
7 8
6 2
5 3
4 8
5 9

예제 출력 1

2
4 2

The network described in the input may be represented by the diagram below.

Suppose servers 4ドル$ and 2ドル$ are deactivated, then all applications will not be working as shown below.

  • $b[1] = 2,ドル so application 1ドル$ is not working.
  • A path from server $a[2] = 5$ to server $b[2] = 3$ must pass through server 4ドル,ドル so application 2ドル$ is not working.
  • $a[3] = 4,ドル so application 3ドル$ is not working.
  • A path from server $a[4] = 5$ to server $b[4] = 9$ must pass through both servers 2ドル$ and 4ドル,ドル so application 4ドル$ is not working.

It can be shown that it is not possible to ensure all applications are not working by deactivating a single server. Hence, the robustness of the network is 2ドル$.

Also note that there may exist other selections of 2ドル$ servers that cause all applications to not be working.

예제 입력 2

6 5
1 2
2 3
4 1
3 5
4 6
1 1
2 2
3 3
2 2
4 4

예제 출력 2

4
3 2 4 1

예제 입력 3

8 3
1 2
2 3
3 4
4 5
5 6
6 7
7 8
3 5
8 5
4 4

예제 출력 3

2
4 6

예제 입력 4

6 2
1 2
1 3
1 4
1 5
1 6
2 2
5 6

예제 출력 4

2
2 1

힌트

출처

Olympiad > National Olympiad in Informatics (Singapore) > Qualification > NOI 2023 Qualification 5번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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