CF1149E.Election Promises

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes.

There are nn cities in Byteland, connected by mm one-way roads. Interestingly enough, the road network has no cycles — it's impossible to start in any city, follow a number of roads, and return to that city. Last year, citizens of the ii-th city had to pay hih_i bourles of tax.

Parties will now alternately hold the election conventions in various cities. If a party holds a convention in city vv, the party needs to decrease the taxes in this city to a non-negative integer amount of bourles. However, at the same time they can arbitrarily modify the taxes in each of the cities that can be reached from vv using a single road. The only condition that must be fulfilled that the tax in each city has to remain a non-negative integer amount of bourles.

The first party to hold the convention is Wrong Answer Party. It's predicted that the party to hold the last convention will win the election. Can Wrong Answer Party win regardless of Time Limit Exceeded Party's moves?

在比特兰(Byteland),有两大政党正为即将到来的大选争夺议会席位:错误答案党(Wrong Answer Party)和超时党(Time Limit Exceeded Party)。为了尽可能多地争取市民选票,两党不断承诺将税率一降再降。

比特兰共有 nn 座城市,由 mm 条单向道路连接。有趣的是,该道路网络中不存在环——即不可能从任意一座城市出发,沿若干条道路行走后回到起始城市。去年,第 ii 座城市的市民需缴纳 hih_i 比特兰元(bourles)的税款。

接下来,两党将轮流在不同城市举行竞选集会。若某政党在城市 vv 举行集会,则该政党必须将该城市的税率降至一个非负整数(单位:比特兰元);同时,它还可任意调整所有能从 vv 经一条道路直接到达的城市的税率,唯一约束是:每座城市的税率仍须为非负整数。

首场集会由错误答案党举行。据预测,举行最后一场集会的政党将赢得大选。那么,无论超时党如何应对,错误答案党是否总能获胜?

输入格式

The first line of the input contains two integers nn, mm (1≤n≤200 0001 \leq n \leq 200\,000, 0≤m≤200 0000 \leq m \leq 200\,000) — the number of cities and roads in Byteland.

The next line contains nn space-separated integers h1,h2,…,hnh_1, h_2, \dots, h_n (0≤hi≤1090 \leq h_i \leq 10^9); hih_i denotes the amount of taxes paid in the ii-th city.

Each of the following mm lines contains two integers (1≤u,v≤n1 \leq u, v \leq n, u≠vu \neq v), and describes a one-way road leading from the city uu to the city vv. There will be no cycles in the road network. No two roads will connect the same pair of cities.

We can show that the conventions cannot be held indefinitely for any correct test case.

输入的第一行包含两个整数 nn、mm(1≤n≤200 0001 \leq n \leq 200\,000,0≤m≤200 0000 \leq m \leq 200\,000)——分别表示 ByteLand 中的城市数量和道路数量。

第二行包含 nn 个以空格分隔的整数 h1,h2,…,hnh_1, h_2, \dots, h_n(0≤hi≤1090 \leq h_i \leq 10^9);其中 hih_i 表示第 ii 个城市所缴纳的税额。

接下来的 mm 行,每行包含两个整数(1≤u,v≤n1 \leq u, v \leq n,u≠vu \neq v),描述一条从城市 uu 指向城市 vv 的单向道路。道路网络中不存在环。任意两个城市之间至多只有一条道路相连。

我们可以证明:对于任意合法的测试用例,会议都无法无限期地举行下去。

输出格式

If Wrong Answer Party can win the election, output WIN in the first line of your output. In this case, you're additionally asked to produce any convention allowing the party to win regardless of the opponent's actions. The second line should contain nn non-negative integers h1′,h2′,…,hn′h'_1, h'_2, \dots, h'_n (0≤hi′≤2⋅10180 \leq h'_i \leq 2 \cdot 10^{18}) describing the amount of taxes paid in consecutive cities after the convention. If there are multiple answers, output any. We guarantee that if the party has any winning move, there exists a move after which no city has to pay more than 2⋅10182 \cdot 10^{18} bourles.

If the party cannot assure their victory, output LOSE in the first and only line of the output.

如果“错误答案党”能够赢得选举,则在输出的第一行输出 WIN。在此情况下,你还需构造任意一种能使该党无论对手如何行动均能获胜的方案。第二行应包含 nn 个非负整数 h1′,h2′,…,hn′h'_1, h'_2, \dots, h'_n(满足 0≤hi′≤2⋅10180 \leq h'_i \leq 2 \cdot 10^{18}),表示实施该方案后各连续城市所缴纳的税额。若存在多种可行方案,输出任意一种即可。我们保证:只要该党存在必胜策略,则必存在一种策略,使得没有任何城市需缴纳超过 2⋅10182 \cdot 10^{18} 博尔勒的税款。

如果该党无法确保获胜,则在输出的第一行(也是唯一一行)输出 LOSE。

输入输出样例

  • 输入#1

    4 2
    2 1 1 5
    1 2
    3 4

    输出#1

    WIN
    1 5 1 5
  • 输入#2

    4 2
    1 5 1 5
    1 2
    3 4

    输出#2

    LOSE
  • 输入#3

    3 3
    314 159 265
    1 2
    1 3
    3 2

    输出#3

    WIN
    0 0 0
  • 输入#4

    6 4
    2 2 5 5 6 6
    1 3
    2 4
    3 5
    4 6

    输出#4

    LOSE

说明/提示

In the first example, Wrong Answer Party should hold the convention in the city 11. The party will decrease the taxes in this city to 11 bourle. As the city 22 is directly reachable from 11, we can arbitrarily modify the taxes in this city. The party should change the tax to 55 bourles. It can be easily proved that Time Limit Exceeded cannot win the election after this move if Wrong Answer Party plays optimally.

The second example test presents the situation we created after a single move in the previous test; as it's Wrong Answer Party's move now, the party cannot win.

In the third test, we should hold the convention in the first city. This allows us to change the taxes in any city to any desired value; we can for instance decide to set all the taxes to zero, which allows the Wrong Answer Party to win the election immediately.

在第一个例子中,“错误答案党”应在城市 11 举行大会。该党将把该城市的税率降低至 11 博尔勒。由于城市 22 可由城市 11 直接到达,因此我们可以任意修改该城市的税率。“错误答案党”应将税率改为 55 博尔勒。可以轻松证明:在此操作之后,若“错误答案党”采取最优策略,则“超时党”无法赢得选举。

第二个测试样例呈现了上一测试样例经过一次操作后所形成的情形;由于当前轮到“错误答案党”行动,该党无法获胜。

在第三个测试样例中,我们应在第一座城市举行大会。这使得我们能够将任意城市的税率修改为任意期望值;例如,我们可以决定将所有城市的税率均设为零,从而令“错误答案党”立即赢得选举。

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

首页