题库练习 Decreasing Game
← 上一题 下一题 →

A16038 | Decreasing Game

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

This is an interactive problem.

Consider the following game for two players:

- Initially, an array of integers $a_1, a_2, \ldots, a_n$ of length $n$ is written on blackboard.
- Game consists of rounds. On each round, the following happens:
- The first player selects any $i$ such that $a_i \gt 0$ . If there is no such $i$ , the first player loses the game (the second player wins) and game ends.
- The second player selects any $j \neq i$ such that $a_j \gt 0$ . If there is no such $j$ , the second player loses the game (the first player wins) and game ends.
- Let $d = \min(a_i, a_j)$ . The values of $a_i$ and $a_j$ are simultaneously decreased by $d$ and the next round starts.

It can be shown that game always ends after the finite number of rounds.

You have to select which player you will play for (first or second) and win the game.

输入格式

The first line contains a single integer $n$ ( $1 \le n \le 300$ ) — the length of array $a$ .

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1 \le a_i \le 300$ ) — array $a$ .

输出格式

Interaction begins after reading $n$ and array $a$ .

You should start interaction by printing a single line, containing either "First" or "Second", representing the player you select.

On each round, the following happens:

- If you are playing as the first player, you should print a single integer $i$ ( $1 \le i \le n$ ) on a separate line. After that, you should read a single integer $j$ ( $-1 \le j \le n$ ) written on a separate line.If $j = -1$ , then you made an incorrect move. In this case your program should terminate immediately.

If $j = 0$ , then the second player can't make a correct move and you win the game. In this case your program should also terminate immediately.

Otherwise $j$ is equal to the index chosen by the second player, and you should proceed to the next round.
- If you are playing as the second player, you should read a single integer $i$ ( $-1 \le i \le n$ ) written on a separate line.If $i = -1$ , then you made an incorrect move on the previous round (this cannot happen on the first round). In that case your program should terminate immediately.

If $i = 0$ , then the first player can't make a correct move and you win the game. In this case your program should also terminate immediately.

Otherwise $i$ is equal to the index chosen by first player. In this case you should write single integer $j$ ( $1 \le j \le n$ ) on a separate line and proceed to the next round.

After printing $i$ or $j$ , do not forget to output the end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- see the documentation for other languages.

Hacks

Hacks are disabled in this problem.

输入输出样例

输入 #1
4
10 4 6 3


3

1

0
输出 #1
First
1

2

4
输入 #2
6
4 5 5 11 3 2

2

5

4

6

1

0
输出 #2
Second 

4

4

3

1

3
C++ 编辑器
输入
输出