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 in an interactive problem. There is an unknown tree consisting of n nodes, which has exactly one centroid. You only know n at first, and your task is to find the centroid of the tree. You can ask the distance between any two vertices for at most 2 cdot10^5 times. Note that the interactor is not adaptive. That is, the tree is fixed in each test beforehand and does not depend on your queries. A vertex is called a centroid if its removal splits the tree into subtrees with at most lfloor frac{n}{2} rfloor vertices each. The only line of the input contains an integer n ( 3 <= n <= 7.5 cdot10^4 ) -- the number of nodes in the tree. Start interaction by reading n . To ask a query about the distance between two nodes u, v ( 1 <= u, v <= n ), output "? u v". If you determine that the centroid of the tree is x , use "! x" to report. After printing a query, do not forget to output the end of a line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: Hacks are disabled in this problem. It 's guaranteed that there are at most 500 tests in this problem. Here is an image of the tree from the sample. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
181815826 |
rainboy |
G |
Nov. 20, 2022, 7:30 p.m. |
OK |
GNU C11 |
TESTS |
500 |
2495 |
0 |
|
|
181815782 |
rainboy |
G |
Nov. 20, 2022, 7:30 p.m. |
OK |
GNU C11 |
TESTS |
500 |
2496 |
0 |
|
|
181815815 |
rainboy |
G |
Nov. 20, 2022, 7:30 p.m. |
OK |
GNU C11 |
TESTS |
500 |
2526 |
0 |
|
|
181814976 |
rainboy |
G |
Nov. 20, 2022, 7:20 p.m. |
OK |
GNU C11 |
TESTS |
500 |
2542 |
0 |
|
|
181815794 |
rainboy |
G |
Nov. 20, 2022, 7:30 p.m. |
OK |
GNU C11 |
TESTS |
500 |
2542 |
0 |
|
|
181815766 |
rainboy |
G |
Nov. 20, 2022, 7:30 p.m. |
OK |
GNU C11 |
TESTS |
500 |
2605 |
0 |
|
|
181821118 |
Mahmoud_khalifa23 |
G |
Nov. 20, 2022, 8:43 p.m. |
OK |
GNU C++14 |
TESTS |
500 |
2230 |
17408000 |
|
|
181807646 |
David-M |
G |
Nov. 20, 2022, 6:06 p.m. |
OK |
GNU C++17 |
TESTS |
500 |
1996 |
1536000 |
|
|
181807847 |
David-M |
G |
Nov. 20, 2022, 6:08 p.m. |
OK |
GNU C++17 |
TESTS |
500 |
2089 |
1536000 |
|
|
181807611 |
David-M |
G |
Nov. 20, 2022, 6:06 p.m. |
OK |
GNU C++17 |
TESTS |
500 |
2323 |
1536000 |
|
|
181837667 |
Akramzhan-K-007-25 |
G |
Nov. 21, 2022, 3:42 a.m. |
OK |
GNU C++17 (64) |
TESTS |
500 |
1965 |
26112000 |
|
|
181813421 |
Benq |
G |
Nov. 20, 2022, 7:02 p.m. |
OK |
GNU C++17 (64) |
TESTS |
500 |
2058 |
1126400 |
|
|
181807111 |
Forever_Pursuit |
G |
Nov. 20, 2022, 6:02 p.m. |
OK |
GNU C++20 (64) |
TESTS |
500 |
685 |
3276800 |
|
|
181833703 |
yangster67 |
G |
Nov. 21, 2022, 2:09 a.m. |
OK |
GNU C++20 (64) |
TESTS |
500 |
685 |
3276800 |
|
|
181798925 |
dorijanlendvaj |
G |
Nov. 20, 2022, 4:52 p.m. |
OK |
GNU C++20 (64) |
TESTS |
500 |
2027 |
26316800 |
|
|
181834572 |
cmk666 |
G |
Nov. 21, 2022, 2:30 a.m. |
OK |
GNU C++20 (64) |
TESTS |
500 |
2043 |
14643200 |
|
|
181834588 |
huynhtrankhanh |
G |
Nov. 21, 2022, 2:30 a.m. |
OK |
GNU C++20 (64) |
TESTS |
500 |
2401 |
1536000 |
|
|
181834895 |
huynhtrankhanh |
G |
Nov. 21, 2022, 2:37 a.m. |
OK |
GNU C++20 (64) |
TESTS |
500 |
2885 |
1536000 |
|
|
181834854 |
huynhtrankhanh |
G |
Nov. 21, 2022, 2:37 a.m. |
OK |
GNU C++20 (64) |
TESTS |
500 |
2994 |
1536000 |
|
|
181834871 |
huynhtrankhanh |
G |
Nov. 21, 2022, 2:37 a.m. |
OK |
GNU C++20 (64) |
TESTS |
500 |
3244 |
1536000 |
|
|
remove filters
Back to search problems