303568: CF690A3. Collective Mindsets (hard)
Memory Limit:256 MB
Time Limit:4 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Collective Mindsets (hard)
题意翻译
**【题目描述】** 一共有 $n$ 个僵尸,每个僵尸头上有一个 $1 \sim n$ 之间的数字(**可重复!**),每个僵尸只能看到其他 $n - 1$ 个僵尸头顶的数字,当然,他们也知道自己的编号。 要求提供一种策略,使所有僵尸只利用自己知道的信息**同时**猜自己头顶的数字,保证至少有一个僵尸猜对。 **【输入格式】** 第一行,一个正整数 $T$,表示数据组数。 接下来对于每组数据,第一行包含两个正整数 $n$ 和 $r$,表示僵尸总数与当前僵尸的编号,下一行包括 $n-1$ 个正整数,表示当前僵尸看到的所有其他僵尸头顶的编号是多少(按僵尸编号升序排列)。 **【输出格式】** 对于每组数据输出一行一个整数,表示该僵尸的猜测。 **【数据范围】** $1 \le T \le 50000$,$2 \le n \le 6$,$1 \le r \le n$。题目描述
Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the $ N $ attendees love to play a very risky game... Every zombie gets a number $ n_{i} $ ( $ 1<=n_{i}<=N $ ) written on his forehead. Although no zombie can see his own number, he can see the numbers written on the foreheads of all $ N-1 $ fellows. Note that not all numbers have to be unique (they can even all be the same). From this point on, no more communication between zombies is allowed. Observation is the only key to success. When the cuckoo clock strikes midnight, all attendees have to simultaneously guess the number on their own forehead. If at least one of them guesses his number correctly, all zombies survive and go home happily. On the other hand, if not a single attendee manages to guess his number correctly, all of them are doomed to die! Zombies aren't very bright creatures though, and Heidi has to act fast if she does not want to jeopardize her life. She has one single option: by performing some quick surgery on the brain she managed to get from the chest, she has the ability to remotely reprogram the decision-making strategy of all attendees for their upcoming midnight game! Can you suggest a sound strategy to Heidi which, given the rules of the game, ensures that at least one attendee will guess his own number correctly, for any possible sequence of numbers on the foreheads? Given a zombie's rank $ R $ and the $ N-1 $ numbers $ n_{i} $ on the other attendees' foreheads, your program will have to return the number that the zombie of rank $ R $ shall guess. Those answers define your strategy, and we will check if it is flawless or not.输入输出格式
输入格式
The first line of input contains a single integer $ T $ ( $ 1<=T<=50000 $ ): the number of scenarios for which you have to make a guess. The $ T $ scenarios follow, described on two lines each: - The first line holds two integers, $ N $ ( $ 2<=N<=6 $ ), the number of attendees, and $ R $ ( $ 1<=R<=N $ ), the rank of the zombie who has to make the guess. - The second line lists $ N-1 $ integers: the numbers on the foreheads of all other attendees, listed in increasing order of the attendees' rank. (Every zombie knows the rank of every other zombie.)
输出格式
For every scenario, output a single integer: the number that the zombie of rank $ R $ shall guess, based on the numbers $ n_{i} $ on his $ N-1 $ fellows' foreheads.
输入输出样例
输入样例 #1
4
2 1
1
2 2
1
2 1
2
2 2
2
输出样例 #1
1
2
2
1
输入样例 #2
2
5 2
2 2 2 2
6 4
3 2 6 1 2
输出样例 #2
5
2