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

27101번 - Metric Matrices 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB25513011950.211%

문제

Given as input a square distance matrix, where a[i,j] is the distance between point i and point j, determine if the distance matrix is "a metric" or not.

A distance matrix a[x,y] is a metric if and only if

  1. f(x,x) = 0
  2. f(x,y) > 0 if x != y
  3. f(x,y) = f(y,x)
  4. f(x,y) + f(y,z) >= f(x,z)

입력

  • Line 1: One integer, N, the rows and number of columns, 2 ≤ N ≤ 30
  • Line 2..N+1: N lines, each with N space-separated integers (-32000 ≤ each integer ≤ 32000). The first of these lines represents the first row; the first number in each line is the first column.

출력

A single line with a single digit, which is the lowest digit of the possible facts on this list:

  • 0: The matrix is a metric
  • 1: The matrix is not a metric, it violates rule 1 above
  • 2: The matrix is not a metric, it violates rule 2 above
  • 3: The matrix is not a metric, it violates rule 3 above
  • 4: The matrix is not a metric, it violates rule 4 above

제한

예제 입력 1

4
0 1 2 3
1 0 1 2
2 1 0 1
3 2 1 0

예제 출력 1

0

힌트

출처

Olympiad > USA Computing Olympiad > 1999-2000 Season > USACO Spring 2000 Contest > Orange 4번

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

출처

대학교 대회

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

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