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.
Problems
B'This is an interactive problem. Kostyanych has chosen a complete undirected graph ^{ dagger} with n vertices, and then removed exactly (n - 2) edges from it. You can ask queries of the following type: Find a Hamiltonian path ^{ ddagger} in the original graph in at most n queries. It can be proven that under these constraints, a Hamiltonian path always exists. ^{ dagger} A complete undirected graph is a graph in which there is exactly one undirected edge between any pair of distinct vertices. Thus, a complete undirected graph with n vertices contains frac{n(n-1)}{2} edges. ^{ ddagger} A Hamiltonian path in a graph is a path that passes through each vertex exactly once. Each test consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 1000 ) -- the number of test cases. The description of the test cases follows. The only line of each test case contains a single integer n ( 2 <= n <= 10^5 ) -- the number of vertices in the graph. It is guaranteed that the sum of n over all test cases does not exceed 10^5 . Interaction for each test case begins with reading the integer n . Then you can make no more than n queries. To make a query, output a line in the format "? d " (without quotes) ( 0 <= d <= n - 1 ). After each query, read two integers -- the answer to your query. When you are ready to report the answer, output a line in the format "! v_1 v_2 ldots v_n " (without quotes) -- the vertices in the order of their occurrence in the Hamiltonian path. Outputting the answer does not count as one of the n queries. After solving one test case, the program should immediately move on to the next one. After solving all test cases, the program should be terminated immediately. If your program makes more than n queries for one test case or makes an incorrect query, then the response to the query will be -1$$'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
264536336 |
ciuim |
F |
June 7, 2024, 4:09 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
25 |
749 |
6963200 |
|
|
264503588 |
pratham.programming7 |
F |
June 6, 2024, 6:34 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
25 |
827 |
1638400 |
|
|
264496669 |
StarSilk |
F |
June 6, 2024, 5:40 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
25 |
999 |
3276800 |
|
|
264499807 |
Elaina |
F |
June 6, 2024, 6:03 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
687 |
1536000 |
|
|
264494377 |
liympanda |
F |
June 6, 2024, 5:27 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
718 |
512000 |
|
|
264503297 |
Noche_6 |
F |
June 6, 2024, 6:31 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
750 |
204800 |
|
|
264538935 |
theRealChainman |
F |
June 7, 2024, 4:38 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
765 |
6860800 |
|
|
264506496 |
Mohamedtarekfayez |
F |
June 6, 2024, 7:05 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
765 |
9318400 |
|
|
264500561 |
Elaina |
F |
June 6, 2024, 6:09 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
827 |
4710400 |
|
|
264508030 |
Larry1010 |
F |
June 6, 2024, 7:23 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
842 |
10137600 |
|
|
264503165 |
Team4_NamHai |
F |
June 6, 2024, 6:30 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
843 |
0 |
|
|
264535780 |
x_wq |
F |
June 7, 2024, 4:02 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
890 |
1638400 |
|
|
264524902 |
Nevll |
F |
June 7, 2024, 1:09 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
952 |
1945600 |
|
|
264525234 |
Kriz_Wu |
F |
June 7, 2024, 1:16 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
624 |
4198400 |
|
|
264534081 |
lprdsb |
F |
June 7, 2024, 3:40 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
655 |
4812800 |
|
|
264493482 |
Nika_Tamliani |
F |
June 6, 2024, 5:23 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
671 |
16486400 |
|
|
264485835 |
lmlmlm |
F |
June 6, 2024, 4:28 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
702 |
102400 |
|
|
264541927 |
liguanghan1 |
F |
June 7, 2024, 5:09 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
702 |
14540800 |
|
|
264526163 |
sunkuangzheng |
F |
June 7, 2024, 1:36 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
718 |
4915200 |
|
|
264526133 |
sunkuangzheng |
F |
June 7, 2024, 1:35 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
718 |
4915200 |
|
|
264542056 |
TMM233 |
F |
June 7, 2024, 5:10 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
718 |
9728000 |
|
|
264496350 |
Nullptrs |
F |
June 6, 2024, 5:38 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
734 |
14540800 |
|
|
264506266 |
beiyuli |
F |
June 6, 2024, 7:03 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
734 |
19353600 |
|
|
264542184 |
Au5 |
F |
June 7, 2024, 5:11 a.m. |
OK |
Kotlin 1.9 |
TESTS |
25 |
1827 |
19148800 |
|
|
264541485 |
Au5 |
F |
June 7, 2024, 5:04 a.m. |
OK |
Kotlin 1.9 |
TESTS |
25 |
1890 |
19148800 |
|
|
264545302 |
Sparkle_Twilight |
F |
June 7, 2024, 5:41 a.m. |
OK |
Kotlin 1.9 |
TESTS |
25 |
1890 |
20787200 |
|
|
264543864 |
Au5 |
F |
June 7, 2024, 5:27 a.m. |
OK |
Kotlin 1.9 |
TESTS |
25 |
1890 |
20787200 |
|
|
264538656 |
fedimser |
F |
June 7, 2024, 4:34 a.m. |
OK |
PyPy 3-64 |
TESTS |
25 |
1889 |
17920000 |
|
|
264539706 |
fedimser |
F |
June 7, 2024, 4:46 a.m. |
OK |
PyPy 3-64 |
TESTS |
25 |
1890 |
19763200 |
|
|
264538922 |
fedimser |
F |
June 7, 2024, 4:38 a.m. |
OK |
PyPy 3-64 |
TESTS |
25 |
1921 |
18841600 |
|
|
264538332 |
fedimser |
F |
June 7, 2024, 4:31 a.m. |
OK |
PyPy 3-64 |
TESTS |
25 |
1921 |
19558400 |
|
|
264539362 |
fedimser |
F |
June 7, 2024, 4:42 a.m. |
OK |
PyPy 3-64 |
TESTS |
25 |
2078 |
19763200 |
|
|
remove filters
Back to search problems