問題一覧 > 通常問題

No.768 Tapris and Noel play the game on Treeone

レベル : / AI推定難易度 : 2225 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 46
作問者 : polylogK / テスター : lumc_
お気に入りにしたユーザー ProblemId : 2085 / 自分の提出
問題文最終更新日: 2018-12-17 22:09:03
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Advent Calendar Contest 2018 (順位表) の他の問題:

Problem Statement

One day, Noel and Tapris played a game using their friend Treeone.
The game follows the rules below.

  • 0. Treeone is a tree with $N$ vertices, with nothing written on any vertex. First, Noel chooses any 1 vertex she likes and writes the letter "N" on it.
  • 1. Tapris chooses 1 vertex with nothing written on it from among the vertices adjacent to the vertex on which the letter "N" is written, and writes the letter "T" on it.
  • 2. Noel chooses 1 vertex with nothing written on it from among the vertices adjacent to the vertex on which the letter "T" is written, and writes the letter "N" on it.
  • 3. Steps 1 - 2 are repeated; the player who can no longer write loses.

Noel wants to beat Tapris.

Find all vertices from which Noel can win regardless of Tapris's choices.

Input

$N$
$a_1\ b_1$
$a_2\ b_2$
$\vdots$
$a_{N-1}\ b_{N-1}$

The first line contains the number of vertices of the tree, $N(2\le N\le 10^5)$.
Each of the following N - 1 lines contains $a_i$ and $b_i(1\le a_i,\ b_i\le N)$ separated by a space, and edge$_i$ connects vertex $a_i$ and vertex $b_i$.

Output

On the first line, output the number of vertices such that Noel wins if she chooses that vertex first.
From the second line onward, output the vertices such that Noel wins if she chooses that vertex first, in ascending order, separated by newlines (output a newline after the last vertex as well).

If there is no such vertex, output 0.

Sample

Sample 1
Input
6
1 2
1 3
2 4
2 5
2 6
Output
3
4
5
6

By choosing vertex 4, 5, or 6, Noel can win no matter which vertices Tapris chooses.

Sample 2
Input
5
1 2
1 5
2 3
3 4
Output
3
2
4
5

Good luck.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。