結果
| 問題 | No.3669 误差绝不允许 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-04 23:03:46 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 2,158 ms / 3,000 ms |
| + 80µs | |
| コード長 | 1,562 bytes |
| 記録 | |
| コンパイル時間 | 234 ms |
| コンパイル使用メモリ | 96,264 KB |
| 実行使用メモリ | 165,892 KB |
| 最終ジャッジ日時 | 2026-09-04 23:07:48 |
| 合計ジャッジ時間 | 26,715 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
# https://github.com/tyuyu-62/cp-library
from collections import deque, defaultdict
from itertools import permutations, product
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop
from random import randint, shuffle
from time import perf_counter as pc
def II(): return int(input())
def LI(dec=0): return [int(x) - dec for x in input().split()]
def SI(): return input()
def LS(): return list(input().split())
mod = 998244353
inf = 2002002002002002002
import sys
sys.setrecursionlimit(10 ** 6)
input = lambda: sys.stdin.readline().rstrip()
_buf = []
def print(*args, sep=" "): _buf.append(sep.join(map(str, args)))
def debug(*args):
if DEBUG: sys.stdout.write(" ".join(map(str, args)) + "\n")
DEBUG = True
from fractions import Fraction
def solve():
N, M = LI()
g = [[] for _ in range(N)]
for i in range(M):
u, v, a, b = LI(1)
a += 1
b += 1
g[u].append((v, Fraction(a, b)))
g[v].append((u, Fraction(a, b)))
dist = [inf] * N
dist[0] = 0
hq = [(0, 0)]
while hq:
c, v = heappop(hq)
if dist[v] < c: continue
for u, nc in g[v]:
if dist[u] > c + nc:
dist[u] = c + nc
heappush(hq, (dist[u], u))
for i in range(1, N):
res = str(dist[i]).split("/")
if len(res) == 1:
print(res[0], 1)
else:
print(*res)
return
if __name__ == "__main__":
T = 1
# T = II()
for _ in range(T):
solve()
sys.stdout.write("\n".join(_buf) + "\n")