308933: CF1600F. Party Organization

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Party Organization

题意翻译

### 题目描述 在伟大的巴尔提亚岛上居住着 $N$ 个人,编号从 $1$ 到 $N$ ,其中正好有 $M$ 对人彼此为朋友。但他们对于一场成功的聚会有非常严格的规定。 每一场巴尔提亚岛的聚会中有 5 个人,如果聚会上的所有人彼此是朋友(这样他们就可以互相交谈但不需要担心与自己不认识的人交谈),或者聚会中没有两个人彼此是朋友(这样他们就可以与自顾自玩手机而不会被别人打扰),则这是一个成功的聚会。 请帮助巴尔提亚人举办一场成功的聚会,或者告诉他们这是不可能的。   ### 输入格式 第一行包含两个整数, $N$ 和 $M$ ,分别代表居住在巴尔提亚的人数和友谊的数量。 接下来 $M$ 行包含两个整数 $U_i, V_i$ ,意思是 $U_i$ 和 $V_i$ 彼此是朋友。 **一对朋友不会再列表中出现两次 ($[U_i,V_i] \neq [U_j, V_j]$),一个人不能与自己做朋友 ($U_i \neq V_i$)。**   ### 输出格式 如果可以举办成功的派对,输出 5 个数代表哪 5 个人可以参加派对,若有多种方案,输出一种即可。如果无法举办,输出 ```-1``` 。   ### 样例 #### 输入 #1 ``` 6 3 1 4 4 2 5 4 ``` #### 输出 #1 ```1 2 3 5 6``` #### 输入 #2 ``` 5 4 1 2 2 3 3 4 4 5 ``` #### 输出 #2 ```-1```   ### 数据范围 $ 5 \leqslant N \leqslant 2 \times 10^5 $ $ 1 \leqslant M \leqslant 2 \times 10^5 $

题目描述

On the great island of Baltia, there live $ N $ people, numbered from $ 1 $ to $ N $ . There are exactly $ M $ pairs of people that are friends with each other. The people of Baltia want to organize a successful party, but they have very strict rules on what a party is and when the party is successful. On the island of Baltia, a party is a gathering of exactly $ 5 $ people. The party is considered to be successful if either all the people at the party are friends with each other (so that they can all talk to each other without having to worry about talking to someone they are not friends with) or no two people at the party are friends with each other (so that everyone can just be on their phones without anyone else bothering them). Please help the people of Baltia organize a successful party or tell them that it's impossible to do so.

输入输出格式

输入格式


The first line contains two integer numbers, $ N $ ( $ 5 \leq N \leq 2*10^5 $ ) and $ M $ ( $ 0 \leq M \leq 2*10^5 $ ) – the number of people that live in Baltia, and the number of friendships. The next $ M $ lines each contains two integers $ U_i $ and $ V_i $ ( $ 1 \leq U_i,V_i \leq N $ ) – meaning that person $ U_i $ is friends with person $ V_i $ . Two friends can not be in the list of friends twice (no pairs are repeated) and a person can be friends with themselves ( $ U_i \ne V_i $ ).

输出格式


If it's possible to organize a successful party, print $ 5 $ numbers indicating which $ 5 $ people should be invited to the party. If it's not possible to organize a successful party, print $ -1 $ instead. If there are multiple successful parties possible, print any.

输入输出样例

输入样例 #1

6 3
1 4
4 2
5 4

输出样例 #1

1 2 3 5 6

输入样例 #2

5 4
1 2
2 3
3 4
4 5

输出样例 #2

-1

Input

题意翻译

### 题目描述 在伟大的巴尔提亚岛上居住着 $N$ 个人,编号从 $1$ 到 $N$ ,其中正好有 $M$ 对人彼此为朋友。但他们对于一场成功的聚会有非常严格的规定。 每一场巴尔提亚岛的聚会中有 5 个人,如果聚会上的所有人彼此是朋友(这样他们就可以互相交谈但不需要担心与自己不认识的人交谈),或者聚会中没有两个人彼此是朋友(这样他们就可以与自顾自玩手机而不会被别人打扰),则这是一个成功的聚会。 请帮助巴尔提亚人举办一场成功的聚会,或者告诉他们这是不可能的。   ### 输入格式 第一行包含两个整数, $N$ 和 $M$ ,分别代表居住在巴尔提亚的人数和友谊的数量。 接下来 $M$ 行包含两个整数 $U_i, V_i$ ,意思是 $U_i$ 和 $V_i$ 彼此是朋友。 **一对朋友不会再列表中出现两次 ($[U_i,V_i] \neq [U_j, V_j]$),一个人不能与自己做朋友 ($U_i \neq V_i$)。**   ### 输出格式 如果可以举办成功的派对,输出 5 个数代表哪 5 个人可以参加派对,若有多种方案,输出一种即可。如果无法举办,输出 ```-1``` 。   ### 样例 #### 输入 #1 ``` 6 3 1 4 4 2 5 4 ``` #### 输出 #1 ```1 2 3 5 6``` #### 输入 #2 ``` 5 4 1 2 2 3 3 4 4 5 ``` #### 输出 #2 ```-1```   ### 数据范围 $ 5 \leqslant N \leqslant 2 \times 10^5 $ $ 1 \leqslant M \leqslant 2 \times 10^5 $

加入题单

算法标签: