結果
問題 | No.1393 Median of Walk |
ユーザー | tpyneriver |
提出日時 | 2020-11-13 08:45:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,756 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 79,232 KB |
最終ジャッジ日時 | 2024-07-19 22:48:41 |
合計ジャッジ時間 | 4,982 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
52,352 KB |
testcase_01 | AC | 42 ms
52,224 KB |
testcase_02 | AC | 42 ms
52,096 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 49 ms
59,008 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 61 ms
63,616 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 41 ms
52,352 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
ソースコード
import sys readline = sys.stdin.readline MOD = 10**9+7 N, M = map(int, readline().split()) cEdge = [] Edge = [[] for _ in range(N)] for _ in range(M): u, v, w = map(int, readline().split()) u -= 1 v -= 1 cEdge.append((w, u, v)) Edge[u].append((w, v)) cEdge.sort() used = set() ans = [-1]*N block = 2* + 10 geta = N + 3 used.add(geta) for w, u, v in cEdge: stack = [geta] for c in range(block-1): unode = u*block + c vnode = v*block + c + 1 if unode in used and vnode not in used: used.add(vnode) stack.append(vnode) if c + 1 >= geta and ans[v] == -1: ans[v] = w for c in range(1, block): unode = u*block + c vnode = v*block + c - 1 if unode in used and vnode not in used: used.add(vnode) stack.append(vnode) if c - 1 >= geta and ans[v] == -1: ans[v] = w while stack: node = stack.pop() vn, c = divmod(node, block) for wi, vf in Edge[vn]: if wi <= w: if c + 1 < block: vfnode = vf*block + c + 1 if vfnode not in used: used.add(vfnode) stack.append(vfnode) if ans[vf] == -1 and c+1 >= geta: ans[vf] = w else: if c - 1 >= 0: vfnode = vf*block + c - 1 if vfnode not in used: used.add(vfnode) stack.append(vfnode) if ans[vf] == -1 and c-1 >= geta: ans[vf] = w print('\n'.join(map(str, ans[1:])))