시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 142 | 66 | 57 | 49.565% |
Zahhak, the enemy of Jamshid, has captured Jamshid's daughters, Arnavaz and Shahrnaz. But he decided to offer them an opportunity to free themselves by solving a puzzle.
Zahhak has an $8 \times 8$ chessboard with cells labeled from $0$ to $63$, as in the figure. He has put a coin on each of the $64$ cells. The cell with label $c$ has a special coin which is physically identical to the other coins, but it is cursed. Each coin is facing either heads or tails.
Zahhak invited the sisters to dinner to describe the puzzle: after the dinner, the sisters should go to different rooms. Then Zahhak goes to Arnavaz's room, presents her the chessboard and tells her the value of $c$ (the label of the cell containing the cursed coin). Arnavaz cannot change the position of the coins but can flip (turn over) at least $1$ and at most $k$ coins. She might flip the same coin several times. Then Zahhak goes to the other room and presents the chessboard to Shahrnaz. If she finds the cursed coin, both sisters will be freed. The sisters can agree on a strategy during the dinner, but cannot communicate afterward.
Your task is to help the sisters solve Zahhak's puzzle.
You should implement two different procedures:
int[] coin_flips(int[] b, int c)
int find_coin(int[] b)
There are $T$ scenarios. For each scenario, the grader calls the procedure coin_flips
. Based on its returned value, the grader updates the chessboard and calls the procedure find_coin
. Note that in the judging system these procedures are called in separate programs. In the first program, procedure coin_flips
is called once for each scenario. Invocations of procedure find_coin
are made in the second program. The behavior of your implementation for each scenario must be independent of the order of the scenarios, as scenarios might not have the same order in the two programs.
Suppose the sisters decide that Arnavaz only flips the cursed coin and Shahrnaz reports the position of one of the coins with tails facing up, or $0$ if there is no such coin. Clearly, this is just an example, not a correct strategy.
The grader makes the following procedure call:
coin_flips([0,0,...,0,0], 63)
In this example, $b$ is an array of length $64$ filled with $0$'s which means all coins on the chessboard have heads facing up. This procedure returns an integer array of length $1$, containing a single value $[63]$.
Then the grader flips the coin in the cell number $63$ and makes the following procedure call:
find_coin([0,0,...,0,1])
This procedure returns $63$, and it is the correct position of the cursed coin.
번호 | 배점 | 제한 |
---|---|---|
1 | 10 | $c < 2$, $k = 1$ |
2 | 15 | $c < 3$, $k = 1$ |
3 | 10 | $k = 64$ |
4 | 15 | $k = 8$ |
5 | 50 | $k = 1$ |
The sample grader reads the input in the following format:
0
/1
) string of length $8$ representing row $j$ of table $b$The sample grader writes the output in the following format:
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)