QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#961. Smol Vertex Cover

Statistics

無向グラフが与えられるので、最小頂点被覆を求めよ。驚くべきことだろう?

最大マッチングのサイズを $M$、最小頂点被覆のサイズを $C$ とする。最小頂点被覆が「smol」である、すなわち $C \le M + 1$ を満たす場合、その最小頂点被覆を求めよ。

入力

各テストケースは複数のテストケースを含む。最初の行にはテストケースの数 $T$ ($1 \le T \le 10^4$) が含まれる。 続いて各テストケースの説明が続く。

各テストケースの最初の行には、2つの整数 $n$ と $m$ ($1 \le n \le 500, 0 \le m \le \frac{n(n-1)}{2}$) が含まれる。これらはグラフの頂点数と辺の数を表す。 続く $m$ 行にはグラフの辺が記述されており、各行には2つの整数 $u$ と $v$ ($1 \le u < v \le n$) が含まれる。これは頂点 $u$ と $v$ が辺で結ばれていることを表す。頂点には $1$ から $n$ までの番号が付けられている。

グラフに多重辺は含まれないことが保証される。 すべてのテストケースにおける $n^2$ の総和は $250\,000$ を超えないことが保証される。

出力

各テストケースについて、最小頂点被覆が smol である場合、そのサイズ $C$ を1行目に出力し、続いて頂点被覆を構成する $C$ 個の異なる頂点をスペース区切りで2行目に出力せよ。そうでない場合は、1行に "not smol" と出力せよ(引用符は含めない)。

smol な最小頂点被覆が複数存在する場合は、そのうちのいずれかを出力すればよい。

入出力例

入力 1

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

出力 1

3
2 3 5

入力 2

2
3 0
5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

出力 2

0
not smol

注記

頂点被覆とは、すべての辺について少なくとも一方の端点がその集合に含まれるような頂点の集合のことである。 マッチングとは、どの2つの辺も共通の端点を持たないような辺の集合のことである。 最小頂点被覆であっても、それが smol でない場合は正解として受け入れられないことに注意せよ。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#321EditorialOpen题解jiangly2025-12-14 07:04:45View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.