QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#846. 传送门

統計

長さ $n$ のチェーン上にいます。あなたはいくつかのポータルを使って他の場所に移動することができます。ポータルの使用には時間がかかります。各位置について、そこに到達するための最短時間を計算してください。到達不可能な場合は $-1$ と出力してください。

ポータルは2つの端で構成されており、一方は $u$ から $v$ までの区間、もう一方は $x$ から $y$ までの区間です。ポータルは双方向です。つまり、$u$ から $v$ までの経路上のどこにいても、ポータルを使って $x$ から $y$ までの経路上のどこへでも移動でき、その逆も可能です。ポータルは複数回使用できます。つまり、$u$ から $v$ までの経路にいる場合、ポータルを2回使うことで $u$ から $v$ までの経路上のどこへでも移動できます。

入力

1行目に3つの正整数 $n, m, s$ が与えられます。これらはそれぞれノード数、ポータル数、あなたの現在地を表します。

続く $m$ 行には、それぞれ5つの整数 $u\ v\ x\ y\ t$ が与えられます。これは、ポータルの両端の区間と、移動にかかる時間 $t$ を表します。ここで $1 \le u, v, x, y \le n$ です。

出力

1行に $n$ 個の整数を出力してください。$i$ 番目の整数は $s$ から $i$ に到達するために必要な時間です。到達不可能な場合は $-1$ を出力してください。

入出力例

入力 1

6 2 1
1 1 2 3 0
3 3 5 6 0

出力 1

0 0 0 -1 0 0

小課題

すべてのデータにおいて、$n, m \le 10^3, 0 \le t \le 10^5$ を満たします。

テストケース $n\le$ $m\le$ $t=0$
$1 \sim 3$ $200$ $200$
$4 \sim 6$
$7\sim 8$ $10^3$ $10^3$
$9\sim 10$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.