結果

問題 No.3488 距離の公理
コンテスト
ユーザー shogo314
提出日時 2026-04-03 21:24:57
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 504 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 175 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 59,136 KB
最終ジャッジ日時 2026-04-03 21:25:09
合計ジャッジ時間 1,596 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import product

N = int(input())
D = [list(map(int, input().split())) for i in range(N)]
f1 = all((D[i][j] == 0) == (i == j) for i, j in product(range(N), repeat=2))
f2 = all(D[i][j] == D[j][i] for i, j in product(range(N), repeat=2))
f3 = all(D[i][j] <= D[i][k] + D[k][j] for i, j, k in product(range(N), repeat=3))
f4 = all(D[i][j] <= max(D[i][k], D[k][j]) for i, j, k in product(range(N), repeat=3))
print("Yes" if f1 and f2 and f3 else "No")
print("Yes" if f1 and f2 and f4 else "No")
0