Codeforces Round 1058 (Div. 1)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2159 Codeforces Round 1058 (Div. 1) FINISHED False 9000 16125923 Oct. 12, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 8086 ) A MAD Interactive Problem PROGRAMMING constructive algorithms implementation interactive

This is an interactive problem. There is a secret sequence (a_1, a_2, \ldots, a_{2n-1},a_{2n}), which contains each integer from (1) to (n) exactly twice . Your task is to guess the sequence by using queries of the following type: "? (k\;j_1\;j_2\;\ldots\;j_k)" — select the integer (k) ((1 \le k \le 2n)) and (k) distinct indices (j_1, j_2, \ldots, j_k) ((1 \le j_1 , j_2 , \ldots , j_k \le 2n)). In response to the query, the jury will return (\text{MAD}(a_{j_1}, a_{j_2}, \ldots, a_{j_k})). We define the (\operatorname{MAD}) (Maximum Appearing Duplicate) of an integer sequence as the largest integer that appears at least twice. Specifically, if there is no number that appears at least twice, the (\operatorname{MAD}) value is (0). Some examples are as follows: (\operatorname{MAD}(1, 2, 1) = 1); (\operatorname{MAD}(2, 2, 3, 3) = 3); (\operatorname{MAD}(1, 2, 3, 4) = 0). Please identify the secret sequence using at most (3n) queries . Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 3000)). The description of the test cases follows. The first line of each test case contains one integer (n) ((2 \le n \le 300)). It is guaranteed that the sum of (n^2) over all test cases does not exceed (10^5). After you read this line of input, the interaction begins with your first query. To make a query, output a line (without quotes) in the following format: " ? (k\;j_1\;j_2\;\ldots\;j_k)" ((1 \le k \le 2n), (1 \le j_1 , j_2 , \ldots , j_k \le 2n)) Here, the indices (j_1 , j_2 , \ldots , j_k) which you selected must be pairwise distinct . Then, after each query, read a single integer — the answer to your query. You can make at most (3n) queries of this type. If your program has found the sequence (a), print the line (without quotes) in the following format: " ! $$$a_1\;a_2\;\ldots\;a_{2n-1}\;a_{2n}

Tutorials

Codeforces Round 1058 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
343324398 mban259 A Oct. 12, 2025, 2:52 p.m. OK C# 10 TESTS 13 405 3379200

remove filters

Back to search problems