結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
回転
|
| 提出日時 | 2025-10-15 23:44:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,195 bytes |
| コンパイル時間 | 389 ms |
| コンパイル使用メモリ | 82,712 KB |
| 実行使用メモリ | 78,088 KB |
| 最終ジャッジ日時 | 2025-10-15 23:44:34 |
| 合計ジャッジ時間 | 8,387 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 TLE * 1 -- * 14 |
ソースコード
def main():
import heapq
import sys
input = sys.stdin.readline
N,M = list(map(int,input().split()))
edge = [[] for _ in range(N)]
for _ in range(M):
a,b,c = list(map(int,input().split()))
a -= 1;b -= 1
edge[a].append((b,c))
edge[b].append((a,c))
geta = 10**14+1
def make_hash(a,b,c):
return b * geta * geta + c * geta + a
def read_hash(n):
a = n % geta
n //= geta
c = n % geta
n //= geta
b = n % geta
return a,b,c
INF = 10**18
visited = [[INF,INF] for _ in range(N)]
q = [make_hash(0,0,0), make_hash(0,1,0)]
while(q):
v,use,now = read_hash(heapq.heappop(q))
if(visited[now][use] <= v):continue
visited[now][use] = v
if(not use):
# チケット使用
for a,c in edge[now]:
if(visited[a][1] <= v):continue
heapq.heappush(q,make_hash(v,1,a))
# チケット保持
for a,c in edge[now]:
if(visited[a][use] <= v+c):continue
heapq.heappush(q,make_hash(v+c,use,a))
for i in visited:
print(sum(i))
main()
回転