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 |
|---|---|---|---|---|---|---|
| 1919 | Hello 2024 | FINISHED | False | 9000 | 71853923 | Jan. 6, 2024, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 178 ) | H | Tree Diameter | PROGRAMMING | interactive trees | 3500 |
There is a hidden tree with (n) vertices. The (n-1) edges of the tree are numbered from (1) to (n-1). You can ask the following queries of two types: Give the grader an array (a) with (n - 1) positive integers. For each edge from (1) to (n - 1), the weight of edge (i) is set to (a_i). Then, the grader will return the length of the diameter(^\dagger). Give the grader two indices (1 \le a, b \le n - 1). The grader will return the number of edges between edges (a) and (b). In other words, if edge (a) connects (u_a) and (v_a) while edge (b) connects (u_b) and (v_b), the grader will return (\min(\text{dist}(u_a, u_b), \text{dist}(v_a, u_b), \text{dist}(u_a, v_b), \text{dist}(v_a, v_b))), where (\text{dist}(u, v)) represents the number of edges on the path between vertices (u) and (v). Find any tree isomorphic(^\ddagger) to the hidden tree after at most (n) queries of type 1 and (n) queries of type 2 in any order. (^\dagger) The distance between two vertices is the sum of the weights on the unique simple path that connects them. The diameter is the largest of all those distances. (^\ddagger) Two trees, consisting of (n) vertices each, are called isomorphic if there exists a permutation (p) containing integers from (1) to (n) such that edge ((u), (v)) is present in the first tree if and only if the edge ((p_u), (p_v)) is present in the second tree. The first and only line of input contains a single integer (n) ((3 \le n \le 1000)) — the number of vertices in the tree. Begin the interaction by reading (n). You are allowed to make queries in the following way: "(\mathtt{?}\,1\,a_1\,a_2 \ldots a_{n-1})" ((1 \le a_i \le 10^9)). Then, you should read an integer (k) which represents the length of the diameter. You are only allowed to ask this query at most (n) times. "(\mathtt{?}\,2\,a\,b)" ( |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 240629814 | Mike_Mirzyanov | H | Jan. 7, 2024, 2:17 a.m. | OK | GNU C++17 | TESTS | 40 | 186 | 0 | 3500 | |
| 240615077 | KhaledBadr1 | H | Jan. 6, 2024, 8:08 p.m. | OK | GNU C++17 (64) | TESTS | 40 | 171 | 0 | 3500 | |
| 240615008 | Abdul_Malik_Zarzour8 | H | Jan. 6, 2024, 8:07 p.m. | OK | GNU C++17 (64) | TESTS | 40 | 171 | 0 | 3500 | |
| 240612222 | rainboy | H | Jan. 6, 2024, 7:30 p.m. | OK | GNU C++17 (64) | TESTS | 40 | 171 | 0 | 3500 | |
| 240621035 | Benq | H | Jan. 6, 2024, 9:53 p.m. | OK | GNU C++17 (64) | TESTS | 40 | 171 | 102400 | 3500 | |
| 240618489 | chappy1 | H | Jan. 6, 2024, 9 p.m. | OK | GNU C++17 (64) | TESTS | 40 | 217 | 0 | 3500 | |
| 240630664 | tulshikaa | H | Jan. 7, 2024, 2:35 a.m. | OK | GNU C++20 (64) | TESTS | 40 | 139 | 0 | 3500 | |
| 240639423 | mr.jaja | H | Jan. 7, 2024, 5:13 a.m. | OK | GNU C++20 (64) | TESTS | 40 | 186 | 0 | 3500 | |
| 240614838 | ugly2333 | H | Jan. 6, 2024, 8:05 p.m. | OK | GNU C++20 (64) | TESTS | 40 | 529 | 32051200 | 3500 |
Back to search problems