306645: CF1228F. One Node is Gone
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
One Node is Gone
题意翻译
#### 题目描述 给定一个正整数$n(2\le n\le17)$ 我们将会先生成一个大小为$2^n-1$的完全二叉树,其有一个根 现在以某种规则删去了其中的一个非根节点,具体规则如下: 设删去点为$u$ 那么我们会删去所有$u$的出边,然后将其所有直系儿子与$u$的父亲连一条边,特别的,如果$u$是一个叶子节点,则不会连边. 现在给定一棵树,希望你求出其能否以上述规则通过删除完全二叉树的一个点后得到,如果可以,求出方案数并输出所有方案中$u$的父亲,你需要升序输出 #### 输入格式 第一行一个正整数$n$ 接下来$2^n-3$行,每行描述给定树的一条边 #### 输出格式 第一行输出方案数,若不为$0$,则第二行升序输出所有可能的父亲节点,否则不输出第二行题目描述
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