提出 #58236022


ソースコード 拡げる

from collections import defaultdict
n,m = map(int, input().split())
inf = float("inf")
ans = [inf] * n
for i in range(m):
    u,v,w = map(int, input().split())
    u -=1
    v -=1
    limit = 10**18
    d = 0
    if w > limit:
        d -= w-limit
    if w < -limit:
        d += -limit - w
    if ans[v] == inf and ans[u] == inf:
        ans[v] = w + d
        ans[u] = 0 + d
    elif ans[v] == inf and ans[u] != inf:
        ans[v] = ans[u] + w
    elif ans[v] != inf and ans[u] == inf:
        ans[u] = ans[v] - w


print(*ans)

提出情報

提出日時
問題 D - Hidden Weights
ユーザ newcomer
言語 Python (PyPy 3.10-v7.3.12)
得点 0
コード長 553 Byte
結果 WA
実行時間 199 ms
メモリ 94300 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 400
結果
AC × 3
AC × 5
WA × 24
セット名 テストケース
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt
ケース名 結果 実行時間 メモリ
00_sample_01.txt AC 68 ms 76936 KiB
00_sample_02.txt AC 68 ms 77060 KiB
00_sample_03.txt AC 68 ms 76816 KiB
01_random_01.txt WA 137 ms 89200 KiB
01_random_02.txt WA 185 ms 93880 KiB
01_random_03.txt WA 189 ms 91256 KiB
01_random_04.txt WA 196 ms 94248 KiB
01_random_05.txt WA 106 ms 88448 KiB
01_random_06.txt WA 158 ms 93784 KiB
01_random_07.txt WA 190 ms 93056 KiB
01_random_08.txt WA 199 ms 94000 KiB
01_random_09.txt WA 114 ms 89884 KiB
01_random_10.txt WA 181 ms 93940 KiB
01_random_11.txt WA 182 ms 90816 KiB
01_random_12.txt WA 194 ms 94300 KiB
01_random_13.txt WA 124 ms 89268 KiB
01_random_14.txt WA 190 ms 94284 KiB
01_random_15.txt WA 179 ms 90212 KiB
01_random_16.txt WA 195 ms 93848 KiB
01_random_17.txt WA 142 ms 85752 KiB
01_random_18.txt WA 162 ms 93880 KiB
01_random_19.txt WA 164 ms 86236 KiB
01_random_20.txt WA 194 ms 94208 KiB
02_handmade_01.txt WA 189 ms 94012 KiB
02_handmade_02.txt WA 191 ms 93844 KiB
02_handmade_03.txt WA 192 ms 93708 KiB
02_handmade_04.txt AC 177 ms 93980 KiB
02_handmade_05.txt WA 117 ms 84216 KiB
02_handmade_06.txt AC 181 ms 93760 KiB