結果

問題 No.3488 距離の公理
コンテスト
ユーザー kidodesu
提出日時 2026-04-03 21:24:12
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 585 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,160 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 52,736 KB
最終ジャッジ日時 2026-04-03 21:24:38
合計ジャッジ時間 2,812 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
f0 = f1 = f2 = f3 = 1
A = [list(map(int, input().split())) for _ in range(n)]
for y in range(n):
    for x in range(n):
        if y == x and A[y][x]:
            f0 = 0
        if not A[y][x] and y != x:
            f0 = 0
        if A[y][x] != A[x][y]:
            f1 = 0

for i in range(n):
    for j in range(n):
        for k in range(n):
            if A[i][j] > A[i][k] + A[k][j]:
                f2 = 0
            if A[i][j] > max(A[i][k], A[k][j]):
                f3 = 0

print("Yes" if f0 and f1 and f2 else "No")
print("Yes" if f0 and f1 and f3 else "No")
0