CF1056C.Pick Heroes

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Don't you tell me what you think that I can be

If you say that Arkady is a bit old-fashioned playing checkers, you won't be right. There is also a modern computer game Arkady and his friends are keen on. We won't discuss its rules, the only feature important to this problem is that each player has to pick a distinct hero in the beginning of the game.

There are 22 teams each having nn players and 2n2n heroes to distribute between the teams. The teams take turns picking heroes: at first, the first team chooses a hero in its team, after that the second team chooses a hero and so on. Note that after a hero is chosen it becomes unavailable to both teams.

The friends estimate the power of the ii-th of the heroes as pip_i. Each team wants to maximize the total power of its heroes. However, there is one exception: there are mm pairs of heroes that are especially strong against each other, so when any team chooses a hero from such a pair, the other team must choose the other one on its turn. Each hero is in at most one such pair.

This is an interactive problem. You are to write a program that will optimally choose the heroes for one team, while the jury's program will play for the other team. Note that the jury's program may behave inefficiently, in this case you have to take the opportunity and still maximize the total power of your team. Formally, if you ever have chance to reach the total power of qq or greater regardless of jury's program choices, you must get qq or greater to pass a test.

别告诉我你认为我能做到什么

如果你说阿卡季玩跳棋有点过时,那你就错了。他和朋友们还热衷于一款现代电脑游戏。我们不会讨论它的规则,本题中唯一重要的是:每位玩家在游戏开始时必须选择一个独一无二的英雄。

共有 22 支队伍,每支队伍各有 nn 名玩家,以及 2n2n 个可供分配的英雄。两支队伍轮流选择英雄:首先由第一支队伍为其队伍选择一名英雄,然后第二支队伍选择一名英雄,依此类推。注意:一旦某位英雄被选中,该英雄即对双方队伍均不可用。

朋友们将第 ii 位英雄的力量值估计为 pip_i。每支队伍都希望最大化其队伍所选英雄的总力量值。然而,存在一种例外情况:有 mm 对英雄彼此之间具有特别强的克制关系;因此,当任意一支队伍选择了这样一对中的某个英雄时,另一支队伍必须在下一轮选择该对中的另一个英雄。每位英雄至多属于这样的一对。

本题为交互式问题。你需要编写一个程序,为其中一支队伍最优地选择英雄,而评测系统的程序将为另一支队伍进行操作。注意:评测系统的程序可能表现得并不高效;此时,你必须抓住机会,依然尽可能最大化己方队伍的总力量值。形式化地说:若在任何时刻,无论评测系统程序如何选择,你都有机会使己方队伍的总力量值达到或超过 qq,那么你必须实际达成至少 qq 的总力量值,才能通过该测试用例。

输入格式

The first line contains two integers nn and mm (1≤n≤1031 \le n \le 10^3, 0≤m≤n0 \le m \le n) — the number of players in one team and the number of special pairs of heroes.

The second line contains 2n2n integers p1,p2,…,p2np_1, p_2, \ldots, p_{2n} (1≤pi≤1031 \le p_i \le 10^3) — the powers of the heroes.

Each of the next mm lines contains two integer aa and bb (1≤a,b≤2n1 \le a, b \le 2n, a≠ba \ne b) — a pair of heroes that are especially strong against each other. It is guaranteed that each hero appears at most once in this list.

The next line contains a single integer tt (1≤t≤21 \le t \le 2) — the team you are to play for. If t=1t = 1, the first turn is yours, otherwise you have the second turn.

Hacks

In order to hack, use the format described above with one additional line. In this line output 2n2n distinct integers from 11 to 2n2n — the priority order for the jury's team. The jury's team will on each turn select the first possible hero from this list. Here possible means that it is not yet taken and does not contradict the rules about special pair of heroes.

第一行包含两个整数 nn 和 mm(1≤n≤1031 \le n \le 10^3,0≤m≤n0 \le m \le n)—— 分别表示每支队伍的玩家数量以及特殊英雄对的数量。

第二行包含 2n2n 个整数 p1,p2,…,p2np_1, p_2, \ldots, p_{2n}(1≤pi≤1031 \le p_i \le 10^3)—— 表示各位英雄的力量值。

接下来的 mm 行中,每行包含两个整数 aa 和 bb(1≤a,b≤2n1 \le a, b \le 2n,a≠ba \ne b)—— 表示一对彼此特别克制的英雄。保证该列表中每个英雄至多出现一次。

下一行包含一个整数 tt(1≤t≤21 \le t \le 2)—— 表示你所代表的队伍。若 t=1t = 1,则由你先手;否则你后手。

Hack 方法

为了进行 Hack,请使用上述格式,并额外添加一行。该行需输出 2n2n 个互不相同的、取值范围为 11 到 2n2n 的整数——表示裁判方队伍的优先选取顺序。裁判方队伍在每次轮到其行动时,将从该列表中选择第一个“可行”的英雄。“可行”意味着该英雄尚未被选中,且其选取不违反关于特殊英雄对的规则。

输入输出样例

  • 输入#1

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

    输出#1

    6
    
    5
    
    3
  • 输入#2

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

    输出#2

    5
    
    4
    
    2

说明/提示

In the first example the first turn is yours. In example, you choose 66, the other team is forced to reply with 22. You choose 55, the other team chooses 44. Finally, you choose 33 and the other team choose 11.

In the second example you have the second turn. The other team chooses 66, you choose 55, forcing the other team to choose 11. Now you choose 44, the other team chooses 33 and you choose 22.

在第一个例子中,由你先手。例如,你选择 66,对方队伍被迫回应 22;接着你选择 55,对方队伍选择 44;最后你选择 33,对方队伍选择 11。

在第二个例子中,你后手。对方队伍先选择 66,你选择 55,迫使对方队伍选择 11;接着你选择 44,对方队伍选择 33,最后你选择 22。

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

首页