No.3562 Communicate Sorted Vector
タグ : / 解いたユーザー数 21
作問者 :
jastaway
/ テスター :
👑
yaaya
butsurizuki
Problem Statement
Consider Alice communicating a sequence $A_{1}, \dots, A_{N}$ of length $N$ to Bob. Here, $1 \leq A_{1} < \dots < A_{N} \leq 10^{9}$ holds.
Alice chooses an integer $K$ between $1$ and $N$, inclusive, and can communicate to Bob only $K$ non-empty 01 strings $S_{1}, \dots, S_{K}$. However, using the given integer $Q (= 377)$, the total string length $\sum_{i=1}^{K} |S_i|$ must be at most $Q$.
Bob wants to restore the sequence $A$ given to Alice, using only $N, Q$ and the strings $S_{1}, \dots, S_{K}$ communicated by Alice.
Write programs for Alice and Bob.
Note that partial scores are awarded for the cases $Q=420, 410$.
Input and Output
Your program should first receive input in the following format.
$ \mathrm{Player} $
$ N\ Q $
Here,
$\mathrm{Player}$ is the string Alice or the string Bob,
$N$ is the length of the sequence $A$, and $Q$ is the upper limit on the total length of the strings Alice can output. ( $1 \leq N \leq 14$, $Q \in \{377, 410, 420\}$)
- When $\mathrm{Player} = $
Alice, your program must act as Alice from then on. - When $\mathrm{Player} = $
Bob, your program must act as Bob from then on.
For Alice
Receive the sequence $A$ ( $1 \leq A_{1} < \dots < A_{N} \leq 10^{9}$ ) in the following format.
$A_{1}\ A_{2}\ \dots\ A_{N}$
Then, output the $K$ strings $S_{1}, \dots, S_{K}$ to communicate to Bob, one per line, in the following format.
Here, $1 \leq K \leq N$, each string must consist only of 0 and 1, and the total string length $\sum_{i=1}^{K} |S_{i}|$ must be at most $Q$.
$K$ $S_1$ $S_2$ $\vdots$ $S_K$
For Bob
Receive Alice's output $S_{1}, \dots, S_{K}$ in the following format.
$K$ $S_1$ $S_2$ $\vdots$ $S_K$
Then, restore the sequence $A$ of length $N$ that was given to Alice as input, and output it separated by spaces in the following format.
$A_{1}\ A_{2}\ \dots\ A_{N}$
Notes
- Each time you output, append a newline at the end and flush standard output.
- The judge's result for invalid output is undefined. Note that you may receive TLE or RE rather than WA.
Partial Score
This problem has partial scoring based on subtasks.
| Subtask | Score | Constraints |
|---|---|---|
| 部分点1 | 10% (30 pts) | $Q=420$ |
| 部分点2 | 25% (75 pts) | $Q=410$ |
| 部分点3 | 65% (195 pts) | $Q=377$ |
Sample
Sample 1
When $A=(2, 3, 5)$
Alice's input
Alice
3 380
2 3 5
Alice's output
3
00
111
00000
Bob's input
Bob
3 380
3
00
111
00000
Bob's output
2 3 5
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。