시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB32181768.000%

문제

Given an integer number K, generate a tree with minimum number of nodes such that there are exactly K pairs of nodes (X, Y), where X is an ancestor of Y.

입력

The input (from the console) will contain a single integer number, K – the number of pairs with the specified property.

출력

The output (to the console) will contain N+1 lines, representing the generated tree, the nodes being indexed from 0.

The first line will contain the number N – the number of nodes in the tree.

The following N lines will contain each 2 numbers X and T, separated by a space, with the following meaning: node T is the direct ancestor of node X. If node X doesn’t have a direct ancestor, T will have value -1.

점수

For every test, you will get:

  1. 100% points if Nparticipant = Ncommittee
  2. 80% points if Nparticipant ∈ [Ncommittee+1, Ncommittee+2]
  3. P% points if Nparticipant ≥ Ncommittee + 3, where P = (Ncommittee + 3) / Nparticipant × 50

Ncommittee is the minimum number of nodes that a tree with the specified property can be generated with.

서브태스크

번호배점제한
120

0 ≤ K ≤ 50

230

0 ≤ K ≤ 500

350

0 ≤ K ≤ 109

예제 입력 1

2

예제 출력 1

3
0 -1
1 0
2 0

There are 2 pairs (X, Y), such that X is the ancestor of Y:

  1. (X,Y) = (0, 1)
  2. (X,Y) = (0, 2)

예제 입력 2

4

예제 출력 2

4
0 -1
1 0
2 0
3 2

There are 4 pairs (X, Y), such that X is the ancestor of Y:

  1. (X,Y) = (0, 1)
  2. (X,Y) = (0, 2)
  3. (X,Y) = (0, 3)
  4. (X,Y) = (2, 3)

채점 및 기타 정보

  • 예제는 채점하지 않는다.