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

30172번 - One Node is Gone 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB64360.000%

문제

You have an integer $n$. Let's define following tree generation as McDic's generation:

  1. Make a complete and full binary tree of 2ドル^{n} - 1$ vertices. Complete and full binary tree means a tree that exactly one vertex is a root, all leaves have the same depth (distance from the root), and all non-leaf nodes have exactly two child nodes.
  2. Select a non-root vertex $v$ from that binary tree.
  3. Remove $v$ from tree and make new edges between $v$'s parent and $v$'s direct children. If $v$ has no children, then no new edges will be made.

You have a tree. Determine if this tree can be made by McDic's generation. If yes, then find the parent vertex of removed vertex in tree.

입력

The first line contains integer $n$ (2ドル \le n \le 17$).

The $i$-th of the next 2ドル^{n} - 3$ lines contains two integers $a_{i}$ and $b_{i}$ (1ドル \le a_{i} \lt b_{i} \le 2^{n} - 2$) --- meaning there is an edge between $a_{i}$ and $b_{i}$. It is guaranteed that the given edges form a tree.

출력

Print two lines.

In the first line, print a single integer --- the number of answers. If given tree cannot be made by McDic's generation, then print 0ドル$.

In the second line, print all possible answers in ascending order, separated by spaces. If the given tree cannot be made by McDic's generation, then don't print anything.

제한

예제 입력 1

4
1 2
1 3
2 4
2 5
3 6
3 13
3 14
4 7
4 8
5 9
5 10
6 11
6 12

예제 출력 1

1
3

예제 입력 2

2
1 2

예제 출력 2

2
1 2

예제 입력 3

3
1 2
2 3
3 4
4 5
5 6

예제 출력 3

0

노트

In the first example, 3ドル$ is the only possible answer.

In the second example, there are 2ドル$ possible answers.

In the third example, the tree can't be generated by McDic's generation.

출처

Contest > Codeforces > Codeforces Round 589 (Div. 2) F번

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

출처

대학교 대회

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

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