RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00555

Konstrukcija

Unrated 레이팅 미적용
난이도
1s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

1 sekun\(da / 512\) M\(iB / 110\) points
Let \(G\) be a directed acyclic graph. If \(c\)1, c2, c3, . . . c\(n\) are distinct vertices of \(G\) such that there is a path
from \(c\)1 to \(c\)2, there is a path from \(c\)2 to \(c\)3, . . . and there is a path from \(c@@RISE_MATH_BLOCK_0@@n\), we say that array
\(C\) = (\(c\)1, c2, c3, . . . c\(n\)) is an ordered array starting at \(c\)1 and ending at \(c@@RISE_MATH_BLOCK_1@@i\) and \(c@@RISE_MATH_BLOCK_2@@i\) to \(c\)\(i+1\).
For this definition of an ordered array \(C\) = (\(c\)1, c2, c3, . . . c\(n\)), we define its length len(\(C\)) = \(n\). Therefore,
the length of an ordered array is equal to the number of vertices it holds. Note that the ordered array can
have a length of 1 when holding a single vertex which represents both its beginning and its end.
Also, for an ordered array \(C\) = (\(c\)1, c2, c3, . . . c\(n\)) we can define its sign as sgn(\(C\)) = (−1){len}{C}. For
vertices \(x\) and \(y\) of \(G\), let’s denote with \(S_{x,y}\) a set of all ordered arrays that start in \(x\) and end in \(y\).
Finally, we define the tension between nodes \(x\) and \(y\) as tns(x, y) = ^{P}
{C}{S} {sgn}{C}}^{.} ^{Therefore,} ^{the
tension between nodes \(x\) and \(y\) equals the sum of signs of all ordered arrays that start in \(x\) and end in \(y\).
An integer \(K\) is given. Your task is to construct a directed acyclic graph with at most 1000 vertices and
at most 1000 edges for which tns(1, N) = \(K\) holds. Number \(N\) in the previous expression denotes the
number of vertices in a graph. Vertices of a graph should be indexed using positive integers from 1 to \(N\).

제약

Subtask
Score
Constraints
1
15
\(1 \le K < 500\)
2
15
\(300 < K \le 1\)
3
20
|\(K\)| < 10000
4
60
No additional constraints.
1 sekun\(da / 512\) M\(iB / 110\) points

입력 형식

The first line contains an integer \(K\) (|\(K\)| ≤\(10^{18}\)) from the task description.

출력 형식

In the first line you should output the number of vertices and the number of edges of the constructed
graph. Let’s denote the number of vertices of that graph with \(N\) (\(1 \le N \le 1000\)), and the number of
edges with \(M\) (\(0 \le M \le 1000\)).
In the \(i-th\) of the next \(M\) lines you should output two distinct integers \(X@@RISE_MATH_BLOCK_0@@i\) (\(1 \le X@@RISE_MATH_BLOCK_1@@i\) towards vertex with index \(Y\)\(i\). Each
edge must appear only once in the output.
Also, the absolute value of tension between each two nodes in the graph must be less or equal to \(2^{80}\).
If there are multiple solutions, output any of them.

예제 1
입력
0
출력
6 6
1 4
1 5
4 3
5 3
3 2
2 6
예제 2
입력
1
출력
1 0
예제 3
입력
2
출력
6 8
1 2
1 3
1 4
1 5
5 4
2 6
3 6
4 6
설명

Clarification of the first example: The constructed graph has 6 vertices.
Ordered arrays that
start in 1 and end in 6 are: (1, 6), (1, 4, 6), (1, 5, 6), (1, 3, 6), (1, 2, 6), (1, 4, 3, 6), (1, 4, 2, 6), (1, 5, 3, 6),
(1, 5, 2, 6), (1, 3, 2, 6), (1, 4, 3, 2, 6), (1, 5, 3, 2, 6). Their lengths are (in order): 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, so
their signs are −1, 1, 1, 1, 1, −1, −1, −1, −1, −1, 1, 1. Therefore, the tension between 1 and 6 is equal to
−1 + 1 + 1 + 1 + 1 −1 −1 −1 −1 −1 + 1 + 1 = 0.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2019/2020 Contest 6

평가 및 의견

Konstrukcija

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Konstrukcija

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8