結果
| 問題 | No.3564 Awkward Timing |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-06-09 08:15:13 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,153 ms / 2,000 ms |
| コード長 | 904 bytes |
| 記録 | |
| コンパイル時間 | 171 ms |
| コンパイル使用メモリ | 85,448 KB |
| 実行使用メモリ | 154,368 KB |
| 最終ジャッジ日時 | 2026-06-09 08:16:04 |
| 合計ジャッジ時間 | 41,283 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
| 純コード判定待ち |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点1 | 40 % | AC * 38 |
| 満点 | 60 % | AC * 62 |
| 合計 | 100 点 |
ソースコード
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
from math import gcd
N,M,K=list(map(int,input().split()))
E=[[] for i in range(N)]
for i in range(M):
x,y,t=list(map(int,input().split()))
x-=1
y-=1
E[x].append((y,t))
E[y].append((x,t))
DIS=[float("inf")]*N
DIS[0]=0
Q=[(0,0)]
while Q:
time,ind=heappop(Q)
if DIS[ind]!=time:
continue
for to,cost in E[ind]:
if DIS[to]>DIS[ind]+cost:
DIS[to]=DIS[ind]+cost
heappush(Q,(DIS[to],to))
DIS2=[1<<63]*N
DIS2[N-1]=0
Q=[(0,N-1)]
while Q:
time,ind=heappop(Q)
if DIS2[ind]!=time:
continue
for to,cost in E[ind]:
if DIS2[to]>DIS2[ind]+cost:
DIS2[to]=DIS2[ind]+cost
heappush(Q,(DIS2[to],to))
g=K
for i in range(N):
for to,t in E[i]:
g=gcd(g,DIS[i]+DIS[to]+t)
x=DIS[N-1]
#print(x,g)
print(x%g)
titia