Graceful Triangles

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

요약
거리가 2 이하인 모든 쌍을 연결한 그래프의 n+2개 정점에 값을 부여해 2n+1개 간선의 차이가 정확히 1부터 2n+1이 되도록 한다.
난이도

어려움10점 중 8점

유형
수학, 그리디, 조합론, 구현
정답자
아직 제출이 없습니다

문제

Consider the following graph in the shape of nn equilateral triangles stitched together horizontally:

This graph has n+2n+2 vertices and 2n+12n+1 edges. The vertices are labeled in the order of increasing horizontal position, as in the image above.

In other words, the graph has n+2n+2 vertices labeled from 11 through n+2n+2, and 2n+12n+1 edges connecting all pairs of vertices whose labels differ by at most 22.

A positive integer value is assigned to each vertex. Vertex ii has the value of v_iv\_i. The value of an edge that connects vertices ii and jj is ∣v_i−v_j∣|v\_i-v\_j|. Find a way to assign values to all vertices so that for every positive integer kk up to 2n+12n+1 inclusive, exactly one edge has the value of kk. The value of any vertex cannot exceed 101810^{18}.

입력

The first line contains nn, a positive integer.

출력

If a solution exists for the given nn, print the values assigned to the vertices 1,2,…,n+21,2,\ldots ,n+2 in one line, separated by spaces. The values must be positive integers not exceeding 101810^{18}. Otherwise, print −1-1.

제한

  • 1≤n≤200,0001\le n\le 200\\, 000

예제1

  1. 예제 1

    입력
    1
    
    예상 출력
    3 1 4