CF360E.Levko and Game

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Levko loves sports pathfinding competitions in his city very much. In order to boost his performance, Levko spends his spare time practicing. The practice is a game.

The city consists of n intersections connected by m + k directed roads. Two or more roads can connect the same pair of intersections. Besides, there can be roads leading from an intersection to itself.

Levko and Zenyk are playing a game. First Levko stands on intersection _s_1, and Zenyk stands on intersection _s_2. They both want to get to intersection f. The person who does it quicker wins. If they get there at the same time, the game ends with a draw. By agreement both players start simultaneously and move with the same speed.

Levko wants to win very much. He knows the lengths of all the roads in the city. Also he knows that he can change the lengths of some roads (there are k such roads at all) if he pays the government. So, the government can change the length of the i-th road to any integer value in the segment [l__i, r__i] (both borders inclusive). Levko wondered if he can reconstruct the roads so as to win the game and whether he can hope for the draw if he cannot win.

You should consider that both players play optimally well. It is guaranteed that we can get from intersections _s_1 and _s_2 to intersection f.

莱夫科非常热爱他所在城市的体育寻路比赛。为了提升自己的表现,莱夫科利用空闲时间进行练习。这种练习是一种游戏。

该城市由 nn 个交叉路口组成,这些交叉路口通过 m+km + k 条有向道路连接。同一对交叉路口之间可能有多条道路;此外,也可能存在从某个交叉路口指向其自身的道路。

莱夫科与泽尼克正在玩一个游戏。初始时,莱夫科站在交叉路口 s1s_1,泽尼克站在交叉路口 s2s_2。两人都希望到达交叉路口 ff。先到达者获胜;若两人同时到达,则游戏以平局结束。双方约定同时出发,并以相同的速度移动。

莱夫科极其渴望获胜。他知晓城市中所有道路的长度。此外他还知道,他可以通过向政府付费来修改其中某些道路的长度(总共可修改的道路数为 kk 条)。因此,政府可以将第 ii 条道路的长度修改为区间 [li,ri][l_i, r_i] 内的任意整数值(含端点)。

莱夫科想知道:他能否通过对道路长度进行重构,确保自己赢得比赛?如果无法获胜,他是否至少能保证平局?

请注意:双方均采取最优策略进行游戏。题目保证从交叉路口 s1s_1 和 s2s_2 均可到达交叉路口 ff。

输入格式

The first line contains three integers n, m and k (1 ≤ n, m ≤ 104, 1 ≤ k ≤ 100). The second line contains three integers _s_1, _s_2 and f (1 ≤ _s_1, _s_2, f ≤ n).

The next m lines contains the descriptions of the roads that cannot be changed by Levko. Each line contains three integers a__i, b__i and c__i (1 ≤ a__i, b__i ≤ n, 1 ≤ c__i ≤ 109), representing a road from intersection a__i to intersection b__i of length c__i.

The next k lines contains the descriptions of the roads that can be changed by Levko. Each line contains four integers a__i, b__i, l__i and r__i (1 ≤ a__i, b__i ≤ n, 1 ≤ l__i ≤ r__i ≤ 109), representing a road from intersection a__i to intersection b__i, Levko can set the road's length within limits [l__i, r__i].

Consider all intersections numbered from 1 to n. It is guaranteed that you can get from intersections _s_1 and _s_2 to intersection f.

第一行包含三个整数 nn、mm 和 kk(1 ≤ n, m ≤ 1041 ≤ n, m ≤ 10^4,1 ≤ k ≤ 1001 ≤ k ≤ 100)。第二行包含三个整数 s1s_1、s2s_2 和 ff(1 ≤ s1, s2, f ≤ n1 ≤ s_1, s_2, f ≤ n)。

接下来的 mm 行描述了 Levko 无法修改的街道。每行包含三个整数 aia_i、bib_i 和 cic_i(1 ≤ ai, bi ≤ n1 ≤ a_i, b_i ≤ n,1 ≤ ci ≤ 1091 ≤ c_i ≤ 10^9),表示一条从交叉路口 aia_i 到交叉路口 bib_i、长度为 cic_i 的街道。

接下来的 kk 行描述了 Levko 可以修改的街道。每行包含四个整数 aia_i、bib_i、lil_i 和 rir_i(1 ≤ ai, bi ≤ n1 ≤ a_i, b_i ≤ n,1 ≤ li ≤ ri ≤ 1091 ≤ l_i ≤ r_i ≤ 10^9),表示一条从交叉路口 aia_i 到交叉路口 bib_i 的街道,Levko 可将该街道的长度设定在区间 [li, ri][l_i, r_i] 内的任意值。

所有交叉路口编号为 11 至 nn。题目保证可以从交叉路口 s1s_1 和 s2s_2 到达交叉路口 ff。

输出格式

In the first line print string "WIN" (without the quotes) if Levko can win this game, string "DRAW" (without the quotes) if Levko can end the game with a draw and "LOSE" (without the quotes) if he loses for sure.

If the answer is "WIN" or "DRAW", then print on the second line k space-separated integers — the length of the roads Levko sets in the order they occur in the input.

第一行输出字符串 “WIN”(不带引号),如果 Levko 能赢得本局游戏;输出字符串 “DRAW”(不带引号),如果 Levko 能以平局结束游戏;输出字符串 “LOSE”(不带引号),如果 Levko 必败。

若答案为 “WIN” 或 “DRAW”,则在第二行输出 k 个用空格分隔的整数——即 Levko 所设定的道路长度,按其在输入中出现的顺序排列。

输入输出样例

  • 输入#1

    4 1 3
    1 3 4
    3 2 2
    1 2 1 3
    2 4 1 3
    3 4 1 3

    输出#1

    WIN
    1 1 3
  • 输入#2

    4 1 3
    1 3 4
    3 2 2
    1 2 1 3
    2 4 1 3
    3 4 1 2

    输出#2

    DRAW
    1 1 2
  • 输入#3

    5 4 2
    1 2 5
    1 3 3
    1 4 4
    2 3 2
    2 4 3
    3 5 1 5
    4 5 4 7

    输出#3

    LOSE

输入解题思路,AI测评打分。不知道怎么写?

首页