Three-Dimensional Embedding

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

요약
차수가 최대 5인 정점 1600개 이하의 그래프가 주어질 때, 정수 좌표와 격자에 맞춘 3차원 꺾은선으로 모든 간선이 교차하지 않도록 매장을 출력한다.
난이도

어려움10점 중 9점

유형
그래프, 기하, 구현, 시뮬레이션
정답자
아직 제출이 없습니다

문제

An embedding of a graph in a space is a way of placing each vertex at a distinct point in that space and drawing each edge as a simple arc connecting its two vertices, so that no two arcs intersect except at a shared vertex. In this problem, we focus on embeddings in a three-dimensional space under certain conditions.

You are given a simple undirected graph with nn vertices and mm edges, which means there is at most one edge connecting any pair of vertices and each edge connects different vertices. The vertices are numbered from 11 to nn, and the edges are numbered from 11 to mm. Edge jj connects the two distinct vertices v_jv\_j and w_jw\_j. Each vertex is incident to at most five edges.

Find an embedding of the graph such that all of the following conditions are satisfied.

  • Each vertex ii is embedded as a point (x_i,y_i,0)(x\_i , y\_i , 0) in the space. The coordinates x_ix\_i and y_iy\_i must be integers between 00 and 400400, inclusive. All points must have distinct coordinates.
  • Each edge jj is embedded as a polyline (a connected series of line segments) with the embedded points for vertices v_jv\_j and w_jw\_j as its endpoints. Each segment of the polyline must be parallel to the xx-, yy-, or zz-axis. Each node of the polyline must have integer coordinates between 00 and 400400, inclusive. Each polyline must have no more than 3030 nodes, counting its endpoints.
  • Polylines must not have self-intersections. Distinct polylines must not share any point, except when they correspond to edges incident to the same vertex. In that case, they may share only that single endpoint.

입력

The first line of input contains two integers nn and mm (2≤n≤16002 ≤ n ≤ 1600, 1≤m≤40001 ≤ m ≤ 4000). The jj-th of the following mm lines contains two integers v_jv\_j and w_jw\_j (1≤v_j<w_j≤n1 ≤ v\_j < w\_j ≤ n).

The input guarantees that each vertex is incident to at most five edges. Further, there are no parallel edges; that is, if j≠j′j \ne j', (v_j,w_j)≠(v_j′,w_j′)(v\_j , w\_j ) \ne (v\_{j'} , w\_{j'}) holds.

출력

First, output nn lines. The ii-th of these lines should contain two integers x_ix\_i and y_iy\_i, representing the coordinates where vertex ii is embedded. Then, output mm lines, where the jj-th line represents the polyline corresponding to edge jj, using the following format:

kk x′_1x'\_1 y′_1y'\_1 z′_1z'\_1 ⋯\cdots x′_kx'\_k y′_ky'\_k z′_kz'\_k

Here, kk is the number of nodes, which must be between 22 and 3030, inclusive. The points (x′_1,y′_1,z′_1),…,(x′_k,y′_k,z′_k)(x'\_1 , y'\_1 , z'\_1), \dots ,(x'\_k , y'\_k , z'\_k ) are the nodes of the polyline. The first point (x′_1,y′_1,z′_1)(x'\_1 , y'\_1, z'\_1) must be (x_v_j,y_v_j,0)(x\_{v\_j} , y\_{v\_j} , 0), and the last point (x′_k,y′_k,z′_k)(x'\_k , y'\_k, z'\_k) must be (x_w_j,y_w_j,0)(x\_{w\_j} , y\_{w\_j} , 0). Each pair of consecutive points is connected by a segment to form the polyline. Each segment must have a positive length. Two consecutive segments may have the same orientation; for example, both can be parallel to the xx-axis.

The embedding that you output must satisfy all of the conditions mentioned above.

Under the given input constraints, it can be shown that there exists at least one valid output. If there are multiple outputs, any one of them will be accepted.

힌트

Notes on special judging:

You are provided with a command-line tool for local testing. The tool has comments at the top to explain its use.

예제1

  1. 예제 1

    입력
    3 3
    1 2
    1 3
    2 3
    
    예상 출력
    0 0
    400 0
    0 399
    3 0 0 0 100 0 0 400 0 0
    4 0 0 0 0 0 200 0 399 200 0 399 0
    3 400 0 0 400 399 0 0 399 0