| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 31 | 14 | 14 | 53.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:
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 | 4 | $a[i] = b[i]$ |
| 2 | 17 | $u[i] = i,ドル $v[i] = i + 1$ |
| 3 | 14 | $n, m ≤ 15$ |
| 4 | 29 | $n, m ≤ 2000$ |
| 5 | 36 | No additional restrictions |
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
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.
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.
6 5 1 2 2 3 4 1 3 5 4 6 1 1 2 2 3 3 2 2 4 4
4 3 2 4 1
8 3 1 2 2 3 3 4 4 5 5 6 6 7 7 8 3 5 8 5 4 4
2 4 6
6 2 1 2 1 3 1 4 1 5 1 6 2 2 5 6
2 2 1
Olympiad > National Olympiad in Informatics (Singapore) > Qualification > NOI 2023 Qualification 5번