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 the hard version of the problem. The only difference is the limit on the number of queries. This is an interactive problem. You are given a tree of n nodes with node 1 as its root node. There is a hidden mole in one of the nodes. To find its position, you can pick an integer x ( 1 <= x <= n ) to make an inquiry to the jury. Next, the jury will return 1 when the mole is in subtree x . Otherwise, the judge will return 0 . If the judge returns 0 and the mole is not in root node 1 , the mole will move to the parent node of the node it is currently on. Use at most 160 operations to find the current node where the mole is located. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 100 ). The description of the test cases follows. The first line of each test case contains one integer n ( 2 <= n <= 5000 ). The following n-1 lines describe the edges of the tree. Each line contains two space-separated integers u_i and v_i ( 1 <= u_i, v_i <= n ), indicating an edge between nodes u_i and v_i . It is guaranteed that the input data represents a tree. The interactor in this task is not adaptive. In other words, the node where the mole is located at first is fixed in every test case and does not change during the interaction. To ask a query, you need to pick a vertex x ( 1 <= x <= n ) and print the line of the following form: After that, you receive: You can make at most 160 queries of this form for each test case. Next, if your program has found the current node where the mole is located, print the line of the following form: Note that this line is not considered a query and is not taken into account when counting the number of queries asked. After this, proceed to the next test case. If you make more than 160 queries during an interaction, your program must terminate immed'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
271658148 |
omeganot |
E2 |
July 20, 2024, 7:42 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
150 |
999 |
102400 |
|
|
271633518 |
Guslix |
E2 |
July 20, 2024, 4:34 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
149 |
1015 |
102400 |
|
|
271674366 |
antguz |
E2 |
July 20, 2024, 10:31 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
150 |
1046 |
102400 |
|
|
271699047 |
Rigel__ |
E2 |
July 21, 2024, 5:25 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
150 |
1046 |
204800 |
|
|
271697870 |
david_tao |
E2 |
July 21, 2024, 5:12 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
150 |
1077 |
204800 |
|
|
271698230 |
david_tao |
E2 |
July 21, 2024, 5:16 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
150 |
1078 |
204800 |
|
|
271644923 |
TLE_Automaton |
E2 |
July 20, 2024, 5:56 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
149 |
1124 |
14438400 |
|
|
271699816 |
Luzhuoyuan |
E2 |
July 21, 2024, 5:34 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
150 |
1140 |
204800 |
|
|
271691388 |
Hardy_Lee |
E2 |
July 21, 2024, 3:44 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
150 |
1140 |
204800 |
|
|
271692477 |
vectorwyx |
E2 |
July 21, 2024, 3:57 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
150 |
1155 |
204800 |
|
|
271644798 |
ltf0501 |
E2 |
July 20, 2024, 5:55 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
149 |
921 |
102400 |
|
|
271689455 |
Linx |
E2 |
July 21, 2024, 3:20 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
150 |
921 |
3276800 |
|
|
271659064 |
bary |
E2 |
July 20, 2024, 7:50 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
150 |
936 |
307200 |
|
|
271651026 |
Cuer |
E2 |
July 20, 2024, 6:36 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
150 |
937 |
102400 |
|
|
271695413 |
xhuyy |
E2 |
July 21, 2024, 4:37 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
150 |
952 |
204800 |
|
|
271659032 |
TooTrashyToCompete |
E2 |
July 20, 2024, 7:50 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
150 |
952 |
204800 |
|
|
271697928 |
pnlong2706 |
E2 |
July 21, 2024, 5:12 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
150 |
983 |
0 |
|
|
271651887 |
erray |
E2 |
July 20, 2024, 6:43 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
150 |
983 |
102400 |
|
|
271656329 |
Cuer |
E2 |
July 20, 2024, 7:24 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
150 |
984 |
102400 |
|
|
271656057 |
Cuer |
E2 |
July 20, 2024, 7:21 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
150 |
984 |
102400 |
|
|
271702448 |
WTR2007 |
E2 |
July 21, 2024, 6:01 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
150 |
843 |
409600 |
|
|
271683590 |
LOOP0 |
E2 |
July 21, 2024, 1:52 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
150 |
874 |
45158400 |
|
|
271689231 |
Moeebius |
E2 |
July 21, 2024, 3:17 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
150 |
890 |
204800 |
|
|
271646421 |
nothing_lasts_forever |
E2 |
July 20, 2024, 6:04 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
150 |
890 |
8908800 |
|
|
271646057 |
ikaurov |
E2 |
July 20, 2024, 6:02 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
150 |
905 |
204800 |
|
|
271690990 |
Misty7 |
E2 |
July 21, 2024, 3:39 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
150 |
906 |
0 |
|
|
271658379 |
tyr0Whiz |
E2 |
July 20, 2024, 7:44 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
150 |
921 |
0 |
|
|
271651364 |
Lucina |
E2 |
July 20, 2024, 6:39 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
150 |
921 |
18124800 |
|
|
271702434 |
hot_zero |
E2 |
July 21, 2024, 6:01 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
150 |
921 |
145305600 |
|
|
271667407 |
yangster67 |
E2 |
July 20, 2024, 8:39 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
150 |
936 |
204800 |
|
|
271686362 |
supersonicdandelion |
E2 |
July 21, 2024, 2:36 a.m. |
OK |
GNU C11 |
TESTS |
150 |
1264 |
17817600 |
|
|
271687734 |
supersonicdandelion |
E2 |
July 21, 2024, 2:57 a.m. |
OK |
GNU C11 |
TESTS |
150 |
1328 |
8396800 |
|
|
271653032 |
Dukkha |
E2 |
July 20, 2024, 6:54 p.m. |
OK |
Java 21 |
TESTS |
150 |
2140 |
3584000 |
|
|
271642481 |
profchi |
E2 |
July 20, 2024, 5:44 p.m. |
OK |
Java 8 |
TESTS |
149 |
1483 |
1945600 |
|
|
271676703 |
profchi |
E2 |
July 20, 2024, 11:23 p.m. |
OK |
Java 8 |
TESTS |
150 |
1499 |
1843200 |
|
|
271648106 |
jvmusin |
E2 |
July 20, 2024, 6:15 p.m. |
OK |
Kotlin 1.9 |
TESTS |
150 |
2546 |
3174400 |
|
|
271644163 |
toor |
E2 |
July 20, 2024, 5:52 p.m. |
OK |
Rust 2021 |
TESTS |
149 |
968 |
102400 |
|
|
271686013 |
supersonicdandelion |
E2 |
July 21, 2024, 2:31 a.m. |
OK |
Rust 2021 |
TESTS |
150 |
3437 |
0 |
|
|
remove filters
Back to search problems