아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Classical Graph Theory Problem

시간 제한4초메모리 제한1024 MB

요약
연결 그래프의 정점을 같은 크기의 두 집합 S와 V∖S로 나눠 두 집합 모두 전체 그래프를 지배하도록 만든다.
난이도

보통10점 중 7점

유형
그래프, DFS, 트리, 그리디
정답자
아직 제출이 없습니다

문제

Let G=(V,E)G = (V, E) be a connected undirected graph.

A set of vertices SS is called a dominating set if every vertex v∈Vv \in V either belongs to SS, or has a neighbor in SS.

A vertex vv is called a leaf if it has exactly one neighbor.

Graph GG satisfies the following property: every vertex has at most two neighboring leaves.

Find a set S⊂VS \subset V such that:

  • SS is a dominating set in GG;
  • V∖SV \setminus S is a dominating set in GG;
  • ∣S∣=⌊∣V∣2⌋|S| = \lfloor \frac{|V|}{2} \rfloor.

It is guaranteed that such a set always exists.

입력

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains two integers nn and mm, denoting the number of vertices and the number of edges in GG (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5; 1≤m≤5⋅1051 \le m \le 5 \cdot 10^5).

Each of the next mm lines contains two integers x_ix\_i and y_iy\_i, denoting the endpoints of the ii-th edge (1≤x_i,y_i≤n1 \le x\_i, y\_i \le n; x_i≠y_ix\_i \ne y\_i). The graph does not contain loops or multiple edges. Every vertex has at most two neighboring leaves.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5, and the sum of mm over all test cases does not exceed 5⋅1055 \cdot 10^5.

출력

Print ⌊n2⌋\lfloor \frac{n}{2} \rfloor distinct integers s_1,s_2,…,s_⌊n/2⌋s\_1, s\_2, \ldots, s\_{\lfloor n/2 \rfloor}, denoting the vertices belonging to SS in any order (1≤s_i≤n1 \le s\_i \le n).

If there are multiple solutions, print any of them.

예제1

  1. 예제 1

    입력
    2
    6 7
    1 2
    1 3
    2 3
    3 4
    4 5
    4 6
    5 6
    3 2
    1 2
    2 3
    
    예상 출력
    2 3 6
    2