Logo
(追記) (追記ここまで)

8286번 - Road Network 2 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 128 MB396987927.431%

문제

Byteasar is going for a road trip around Byteland. Unfortunately, he was unable to buy a map of the country. From his friends he learned a few properties of the Bytean road network:

  • There are n cities in Byteland, numbered 1 through n.
  • Each road is bidirectional and connects two different cities.
  • Each pair of different cities is connected by exactly one path, consisting of one or more roads, on which no city appears more than once.
  • There are exactly di roads starting at the city number i.

Byteasar is going to reconstruct the road map of Byteland. The number of possible road networks satisfying the conditions can be quite big, so Byteasar will be satisfied with any correct plan.

입력

The first line of input contains one integer n (2 ≤ n ≤ 2,000,000). The second line contains n integers di (1 ≤ di ≤ n-1).

출력

If no road network plan satisfying the conditions from the input exists, the first and only line of output should contain a single word BRAK - i.e., none in Polish. In the opposite case each of the lines in the output should contain a description of one bidirectional road - two different integers in the range [1, n] denoting the numbers of cities connected by this road. Output each road exactly once. The order of roads and cities connected by roads in the output can be arbitrary.

제한

예제 입력 1

6
1 1 3 3 1 1

예제 출력 1

1 3
2 3
3 4
5 4
6 4

힌트

출처

Contest > Algorithmic Engagements > PA 2011 7-0번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /