CF744B.Hongcow's Game
普及+/提高
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem. In the interaction section below you will see the information about flushing the output.
In this problem, you will be playing a game with Hongcow. How lucky of you!
Hongcow has a hidden n by n matrix M. Let M__i, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.
The matrix entries are between 0 and 109. In addition, M__i, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find
.
To do this, you can ask Hongcow some questions.
A question consists of giving Hongcow a subset of distinct indices {_w_1, _w_2, ..., w__k}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of _min_1 ≤ j ≤ k__M__i, w__j.
You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.
When you are ready to answer, print out a single integer - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.
You will get Wrong Answer verdict if
- Your question or answers are not in the format described in this statement.
- You ask strictly more than 20 questions.
- Your question contains duplicate indices.
- The value of k in your question does not lie in the range from 1 to n, inclusive.
- Your final answer is not correct.
You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).
这是一个交互式问题。在下方的交互说明部分,您将看到有关刷新输出的信息。
在本题中,您将与 Hongcow 进行一场游戏。您真幸运!
Hongcow 持有一个隐藏的 n×n 矩阵 M。记 Mi,j 为该矩阵第 i 行、第 j 列的元素。矩阵的行和列均从 1 编号至 n。
所有矩阵元素的取值范围为 0 到 109。此外,对所有合法的 i,均有 Mi,i=0。您的任务是:对每一行,求出排除对角线元素后该行的最小值。形式化地,对每个 i,您必须求出
。
为此,您可以向 Hongcow 提出若干问题。
一个问题由您给出一个互异下标集合 {w1,w2,…,wk} 构成,其中 1≤k≤n。Hongcow 将返回 n 个整数;其中第 i 个整数为 min1≤j≤kMi,wj。
您最多只能向 Hongcow 提出 20 个问题——他认为您只需这么多问题即可得出答案。
当您准备好提交最终答案时,请先单独输出一行整数 −1,然后在下一行输出 n 个整数。其中第 i 个整数应为矩阵第 i 行中排除第 i 个元素后的最小值。请勿忘记刷新最终答案的输出。提交答案本身不计入提问次数。
若出现以下任一情况,您将收到“Wrong Answer”(错误答案)判据:
- 您的问题或答案格式不符合本题描述;
- 您提出的问题严格多于 20 个;
- 您的问题中包含重复下标;
- 您的问题中 k 的值不在 [1,n] 范围内;
- 您的最终答案不正确。
若您未输出任何内容,或忘记刷新输出(包括最终答案),则会收到 “Idleness Limit Exceeded”(空闲超时)判据(有关刷新输出的更多信息见下方)。
输入格式
The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).
输入的第一行包含一个整数 n(2 ≤ n ≤ 1,000)。
输出格式
To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!
要输出最终答案,请单独在一行中输出字符串 -1。接下来的一行应包含 n 个整数,其中第 i 个整数为矩阵第 i 行中除对角线元素外的最小值。请勿忘记刷新输出!
输入输出样例
输入#1
3 0 0 0 2 7 0 0 0 4 3 0 8 0 5 4
输出#1
3 1 2 3 1 3 2 1 2 1 2 1 1 -1 2 5 4
输入#2
2 0 0 0 0
输出#2
1 2 1 1 -1 0 0
说明/提示
In the first sample, Hongcow has the hidden matrix
[
[0, 3, 2],
[5, 0, 7],
[4, 8 ,0],
]
Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant.
3
3
1 2 3
0 0 0
1
3
2 7 0
2
1 2
0 0 4
1
2
3 0 8
1
1
0 5 4
-1
2 5 4
For the second sample, it is possible for off-diagonal elements of the matrix to be zero.
在第一个样例中,Hongcow 拥有如下隐藏矩阵:
[
[0, 3, 2],\
[5, 0, 7],\
[4, 8, 0],
]
以下是一个更易读的版本,用于演示交互过程。左侧一列代表 Hongcow,右侧一列代表参赛者。
3
3
1 2 3
0 0 0
1
3
2 7 0
2
1 2
0 0 4
1
2
3 0 8
1
1
0 5 4
-1
2 5 4
对于第二个样例,矩阵的非对角线元素可能为零。
输入解题思路,AI测评打分。不知道怎么写?