A12500 | Election Promises
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $n$ cities in Byteland, connected by $m$ 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 $i$ -th city had to pay $h_i$ bourles of tax.
Parties will now alternately hold the election conventions in various cities. If a party holds a convention in city $v$ , 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 $v$ 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?
There are $n$ cities in Byteland, connected by $m$ 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 $i$ -th city had to pay $h_i$ bourles of tax.
Parties will now alternately hold the election conventions in various cities. If a party holds a convention in city $v$ , 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 $v$ 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?
输入格式
The first line of the input contains two integers $n$ , $m$ ( $1 \leq n \leq 200\,000$ , $0 \leq m \leq 200\,000$ ) — the number of cities and roads in Byteland.
The next line contains $n$ space-separated integers $h_1, h_2, \dots, h_n$ ( $0 \leq h_i \leq 10^9$ ); $h_i$ denotes the amount of taxes paid in the $i$ -th city.
Each of the following $m$ lines contains two integers ( $1 \leq u, v \leq n$ , $u \neq v$ ), and describes a one-way road leading from the city $u$ to the city $v$ . 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.
The next line contains $n$ space-separated integers $h_1, h_2, \dots, h_n$ ( $0 \leq h_i \leq 10^9$ ); $h_i$ denotes the amount of taxes paid in the $i$ -th city.
Each of the following $m$ lines contains two integers ( $1 \leq u, v \leq n$ , $u \neq v$ ), and describes a one-way road leading from the city $u$ to the city $v$ . 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.
输出格式
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 $n$ non-negative integers $h'_1, h'_2, \dots, h'_n$ ( $0 \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 \cdot 10^{18}$ bourles.
If the party cannot assure their victory, output LOSE in the first and only line of the output.
If the party cannot assure their victory, output LOSE in the first and only line of the output.
输入输出样例
输入 #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 $1$ . The party will decrease the taxes in this city to $1$ bourle. As the city $2$ is directly reachable from $1$ , we can arbitrarily modify the taxes in this city. The party should change the tax to $5$ 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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted