Path Partition

시간 제한15초메모리 제한2048 MB

요약
무작위로 생성된 무방향 그래프의 모든 간선을 길이 3인 경로 M/3개로 분할하는데, 경로의 시작점과 끝점이 같아도 된다.
난이도

어려움10점 중 8점

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

문제

This is an "output-only" problem. The test cases are made available to you. However, due to the large output size, you should still submit a program that reads the input and produces the outputs within the time limit.

Busy Beaver generated a random undirected graph with NN vertices and MM edges, where MM is a multiple of 33. Now, he wants to partition the edges into M/3M/3 paths of length 33 (possibly starting and ending at the same vertex). Can you help Busy Beaver find such a partition?

입력

Please download the test data using this link.

The first line of input contains two integers NN and MM --- the number of vertices and edges in the graph, respectively.

The iith of the next MM lines contains two integers u_iu\_i and v_iv\_i (1≤u_i,v_i≤N,u_i≠v_i1 \le u\_i,v\_i \le N, u\_i \ne v\_i) --- the endpoints of the iith edge.

It is guaranteed that the MM edges were generated randomly. Formally, out of the N(N−1)2\frac{N(N-1)}{2} possible edges, MM distinct edges were chosen uniformly at random without replacement.

출력

Output M/3M/3 lines. The iith line should contain 44 integers a_ia\_i, b_ib\_i, c_ic\_i, and d_id\_i (1≤a_i,b_i,c_i,d_i≤N1 \le a\_i,b\_i,c\_i,d\_i \le N), representing a path using edges (a_i,b_i)(a\_i,b\_i), (b_i,c_i)(b\_i,c\_i), and (c_i,d_i)(c\_i,d\_i).

It is allowed to have a_i=d_ia\_i = d\_i. Your output should satisfy ⋃_i=1M/3a_i,b_i,b_i,c_i,c_i,d_i=⋃_i=1Mu_i,v_i.\bigcup\_{i=1}^{M/3} \\{\\{a\_i,b\_i\\},\\{b\_i,c\_i\\},\\{c\_i,d\_i\\}\\} = \bigcup\_{i=1}^M \\{\\{u\_i,v\_i\\}\\}.

힌트

The sample is provided to illustrate the input and output format. It is not scored.

The sample graph and partition are shown in the figure below. Note that the path 2−5−8−22 - 5 - 8 - 2 starts and ends at the same vertex, which is allowed.

예제1

  1. 예제 1

    입력
    10 15
    3 10
    10 4
    3 6
    5 8
    10 9
    5 2
    1 4
    1 9
    1 7
    8 3
    1 6
    6 10
    10 2
    8 2
    4 3
    
    예상 출력
    2 5 8 2
    8 3 10 2
    3 4 1 7
    6 1 9 10
    3 6 10 4