#P7006. [NEERC2013] Kabaleo Lite

[NEERC2013] Kabaleo Lite

题目描述

Kabaleo Lite is a board game. The board consists of several stacks of conical chips of various colors. Only the color of the top chip of the stack is visible.

Each player has a unique target color and a set of colored chips. The target color is hidden from other players, while the set of chips is visible to them. On his turn, player selects one of his chips and puts it on one of the board stacks, thus recoloring it to the color of the chosen chip.

After the last turn, the number of visible board chips of each color is calculated. The winning color is the color that occurs the maximum times. The player (if any) that has this color as his target color, wins the game. If there is no such player or if there are two or more colors that occur the maximum times, the game ends in a draw.

You are playing your last chip in the Kabaleo Lite game. Other players also have one chip left. You want to determine all possible moves that lead you to winning the game. You do not know the target colors of other players and you cannot predict their moves, so your move must guarantee your victory regardless of moves of your opponents.

输入格式

The first line contains four integers n,p,cn , p , c and hh -- the number of stacks on the board (1n106),(1 \le n \le 10^{6}), the number of players (1p106),(1 \le p \le 10^{6}), the number of chips' colors (pc106),(p \le c \le 10^{6}), and your hidden color (1hc)(1 \le h \le c) .

The second line contains nn integers bib_{i} -- the color of the visible board chip for each stack on the board (1bic)(1 \le b_{i} \le c) .

The third line contains pp integers lil_{i} -- the color of the last chip for each player (1lic)(1 \le l_{i} \le c) . The players are numbered from one (you) to nn in the order of their turns.

输出格式

The first line must contain ww -- the number of winning moves.

The second line must contain ww distinct numbers mim_{i} -- the numbers of the stacks on which your chip should be put to win. Stacks are numbered starting from 11 in the order that their visible colors are given in the input file. You can output their numbers in any order on this line.

Remember, that your move should be winning regardless of the moves of all other players.

题目大意

有一种棋盘游戏:棋盘上有 nn 个格子,每个格子上可以堆叠若干个有颜色的筹码,只有每个格子中最上方的筹码的颜色是可见的。

参加游戏的每个玩家都有各自不同的一个目标颜色,以及一些彩色筹码。每个人只知道自己的目标颜色,但各自拥有的筹码颜色和数量都是公开的。每个回合中,所有玩家轮流在棋盘上选一个格子放置筹码,同时覆盖下方的筹码。游戏结束后,数出棋盘上可见筹码数最多的颜色,以该颜色为目标颜色的玩家即获胜。若该颜色不是任何玩家的目标颜色,或者棋盘上出现最多的颜色不唯一,则游戏平局。

现在,一局游戏进行到了最后,你和其他所有玩家都只剩最后一个筹码。现在恰好轮到你操作,在不知道其他人的目标颜色的前提下,你想知道你一共有哪些操作可以保证必胜。

输入格式

第一行 44 个整数 n,p,c,hn,p,c,h,分别表示棋盘格数、玩家数、筹码颜色总数和你的目标颜色;

第二行 nn 个整数 bib_i,表示棋盘上现有的筹码颜色,棋盘格编号从 11 开始;

第三行 pp 个整数 lil_i,表示每个玩家的最后一枚筹码的颜色,玩家编号从你开始。

输出格式

第一行 11 个整数 ww,表示你有多少种必胜操作。

第二行 ww 个整数 mim_i,表示你应该把筹码放在哪个格子上。顺序不限。

数据范围见原题。

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

1
2

提示

Time limit: 1 s, Memory limit: 128 MB.