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

8073번 - Road Net 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB1451047471.845%

문제

A diskette was enclosed to a road map. The diskette contains the table of the shortest ways (distances) between each pair of towns on the map. All the roads are two-way. The location of towns on the map has the following interesting property: if the length of the shortest way from town A to town B equals the sum of the lengths of the shortest ways from A to C and C to B then town C lies on (certain) shortest way from A to B. We say that towns A and B are neighbouring towns if there is no town C such that the length of the shortest way from A to B equals the sum of the lengths of the shortest ways from A to C and C to B.

Find all the pairs of neighbouring towns.

For the table of distances:

 A B C
A 0 1 2
B 1 0 3
C 2 3 0

the neighbouring towns are A, B and A, C.

Write a program that:

  • reads the table of distances from the standard input;
  • finds all the pairs of neighbouring towns;
  • writes the result to the standard output.

입력

In the first line of the standard input there is an integer n, 1 ≤ n ≤ 200, which equals the number of towns on the map. Towns are numbered from 1 to n.

The table of distances is written in the following n lines. In the (i+1)-st line, 1 ≤ i ≤ n, there are n non-negative integers not greater than 200, separated by single spaces. The j-th integer is the distance between towns i and j.

출력

Your program should write all the pairs of the neighbouring towns (i.e. their numbers) to the standard output. There should be one pair in each line. Each pair can appear only once. The numbers in each pair should be given in increasing order. Pairs should be ordered so that if the pair (a, b) precedes the pair (c, d) then a < c or (a = c and b < d).

제한

예제 입력 1

3
0 1 2
1 0 3
2 3 0

예제 출력 1

1 2
1 3

힌트

출처

Olympiad > Polish Olympiad in Informatics > POI 1997/1998 > Stage 2 1번

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

출처

대학교 대회

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

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