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'The graph is called tree if it is connected and has no cycles. Suppose the tree is rooted at some vertex. Then tree is called to be perfect k -ary tree if each vertex is either a leaf (has no children) or has exactly k children. Also, in perfect k -ary tree all leafs must have same depth. For example, the picture below illustrates perfect binary tree with 15 vertices: There is a perfect k -ary tree with n nodes. The nodes are labeled with distinct integers from 1 to n , however you don 't know how nodes are labelled. Still, you want to find the label of the root of the tree. You are allowed to make at most 60 cdot n queries of the following type: Both a and c are considered to be lying on the path from a to c . When you are ready to report the root of the tree, print It is possible to report the root only once and this query is not counted towards limit of 60 cdot n queries. The first line of the standard input stream contains two integers n and k ( 3 <= n <= 1500 , 2 <= k < n ) -- the number of nodes in the tree and the value of k . It is guaranteed that n is such that the tree forms a perfect k -ary tree. You can ask at most 60 cdot n queries. To ask a query, print a line of form "? a b c ", where 1 <= a, b, c <= n . After that you should read a single line containing "Yes" or "No" depending on the answer of the query. The tree is fixed for each test and it doesn 't depend on your queries. When you are ready to print the answer, print a line of the form "! s ", where s is the label of the root vertex and then terminate your program. After printing each query do not forget to print end of line and flush the output. Otherwise you may get Idleness limit exceeded. To do this, use: In case your program will make more than 60 cdot n queries, but in other aspects would follow the interaction '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
46697075 |
sudoBug |
F |
Dec. 6, 2018, 8:39 p.m. |
OK |
GNU C++11 |
TESTS |
176 |
77 |
204800 |
|
2400 |
48408789 |
CQUzbx |
F |
Jan. 15, 2019, 6:21 a.m. |
OK |
GNU C++11 |
TESTS |
176 |
92 |
0 |
|
2400 |
46086595 |
YaoBIG |
F |
Nov. 22, 2018, 5:36 p.m. |
OK |
GNU C++11 |
TESTS |
176 |
92 |
0 |
|
2400 |
57915214 |
zxyl |
F |
July 29, 2019, 12:39 a.m. |
OK |
GNU C++11 |
TESTS |
176 |
93 |
0 |
|
2400 |
48606225 |
code_struck |
F |
Jan. 20, 2019, 11:03 a.m. |
OK |
GNU C++11 |
TESTS |
176 |
93 |
0 |
|
2400 |
48605981 |
code_struck |
F |
Jan. 20, 2019, 10:55 a.m. |
OK |
GNU C++11 |
TESTS |
176 |
93 |
0 |
|
2400 |
46127779 |
Riqirez |
F |
Nov. 23, 2018, 8:27 p.m. |
OK |
GNU C++11 |
TESTS |
176 |
93 |
0 |
|
2400 |
46086044 |
Miyamizu_Mitsuha |
F |
Nov. 22, 2018, 5:33 p.m. |
OK |
GNU C++11 |
TESTS |
176 |
93 |
512000 |
|
2400 |
48463009 |
mmmod_lqs |
F |
Jan. 16, 2019, 3:43 p.m. |
OK |
GNU C++11 |
TESTS |
176 |
108 |
0 |
|
2400 |
55824238 |
stanislav.bezkorovainyi |
F |
June 20, 2019, 10:03 a.m. |
OK |
GNU C++11 |
TESTS |
176 |
108 |
204800 |
|
2400 |
46101655 |
orz010orz |
F |
Nov. 23, 2018, 6:20 a.m. |
OK |
GNU C++14 |
TESTS |
176 |
77 |
409600 |
|
2400 |
46093939 |
orz010orz |
F |
Nov. 22, 2018, 9:27 p.m. |
OK |
GNU C++14 |
TESTS |
176 |
78 |
409600 |
|
2400 |
46096003 |
supersayadilson |
F |
Nov. 23, 2018, 12:16 a.m. |
OK |
GNU C++14 |
TESTS |
176 |
93 |
204800 |
|
2400 |
46085497 |
hugeh0ge |
F |
Nov. 22, 2018, 5:30 p.m. |
OK |
GNU C++14 |
TESTS |
176 |
108 |
614400 |
|
2400 |
46128238 |
Gnay_Oahnauhz |
F |
Nov. 23, 2018, 8:48 p.m. |
OK |
GNU C++14 |
TESTS |
176 |
109 |
204800 |
|
2400 |
46095909 |
supersayadilson |
F |
Nov. 23, 2018, 12:09 a.m. |
OK |
GNU C++14 |
TESTS |
176 |
109 |
204800 |
|
2400 |
46085674 |
DP_I_J |
F |
Nov. 22, 2018, 5:31 p.m. |
OK |
GNU C++14 |
TESTS |
176 |
109 |
204800 |
|
2400 |
46258047 |
HukuToc |
F |
Nov. 26, 2018, 6:04 p.m. |
OK |
GNU C++14 |
TESTS |
176 |
124 |
0 |
|
2400 |
46192825 |
gs15120 |
F |
Nov. 25, 2018, 6:31 a.m. |
OK |
GNU C++14 |
TESTS |
176 |
124 |
0 |
|
2400 |
52526939 |
aviroop123 |
F |
April 9, 2019, 11:52 a.m. |
OK |
GNU C++14 |
TESTS |
176 |
124 |
204800 |
|
2400 |
47513628 |
wysoowek |
F |
Dec. 26, 2018, 8:20 a.m. |
OK |
GNU C++17 |
TESTS |
176 |
109 |
204800 |
|
2400 |
59696555 |
denis2111 |
F |
Aug. 30, 2019, 8:50 a.m. |
OK |
GNU C++17 |
TESTS |
176 |
124 |
0 |
|
2400 |
46100506 |
dzerzhinski |
F |
Nov. 23, 2018, 5:25 a.m. |
OK |
GNU C++17 |
TESTS |
176 |
124 |
204800 |
|
2400 |
46095577 |
CodeForcesRound523 |
F |
Nov. 22, 2018, 11:40 p.m. |
OK |
GNU C++17 |
TESTS |
176 |
124 |
204800 |
|
2400 |
46238087 |
860579 |
F |
Nov. 26, 2018, 5:29 a.m. |
OK |
GNU C++17 |
TESTS |
176 |
124 |
614400 |
|
2400 |
54021581 |
Lucina |
F |
May 12, 2019, 10:03 a.m. |
OK |
GNU C++17 |
TESTS |
176 |
124 |
716800 |
|
2400 |
55212775 |
RCG |
F |
June 6, 2019, 3:20 p.m. |
OK |
GNU C++17 |
TESTS |
176 |
139 |
102400 |
|
2400 |
46089885 |
dinosaurs |
F |
Nov. 22, 2018, 7:09 p.m. |
OK |
GNU C++17 |
TESTS |
176 |
139 |
409600 |
|
2400 |
46082706 |
Benq |
F |
Nov. 22, 2018, 5:11 p.m. |
OK |
GNU C++17 |
TESTS |
176 |
139 |
409600 |
|
2400 |
55939801 |
rushcheyo |
F |
June 22, 2019, 3:57 p.m. |
OK |
GNU C++17 |
TESTS |
176 |
140 |
0 |
|
2400 |
46089980 |
Martynas |
F |
Nov. 22, 2018, 7:10 p.m. |
OK |
Go |
TESTS |
176 |
264 |
0 |
|
2400 |
46089603 |
Haskell_for_a_pint |
F |
Nov. 22, 2018, 7:06 p.m. |
OK |
Haskell |
TESTS |
176 |
1512 |
23347200 |
|
2400 |
46131268 |
tri |
F |
Nov. 24, 2018, 1:08 a.m. |
OK |
Java 8 |
TESTS |
176 |
218 |
0 |
|
2400 |
52480554 |
xodiac |
F |
April 8, 2019, 5:05 a.m. |
OK |
Java 8 |
TESTS |
176 |
436 |
0 |
|
2400 |
68065882 |
dalt |
F |
Jan. 2, 2020, 7:43 a.m. |
OK |
Java 8 |
TESTS |
176 |
530 |
20582400 |
|
2400 |
52480582 |
xodiac |
F |
April 8, 2019, 5:07 a.m. |
OK |
Java 8 |
TESTS |
176 |
623 |
0 |
|
2400 |
46094489 |
4mda4mda |
F |
Nov. 22, 2018, 10:03 p.m. |
OK |
Java 8 |
TESTS |
176 |
670 |
0 |
|
2400 |
48110535 |
donli |
F |
Jan. 9, 2019, 9:09 a.m. |
OK |
Java 8 |
TESTS |
176 |
716 |
0 |
|
2400 |
66150134 |
humblefoo0l |
F |
Dec. 1, 2019, 6:32 p.m. |
OK |
Java 8 |
TESTS |
176 |
733 |
0 |
|
2400 |
46095373 |
Jeel_Vaishnav |
F |
Nov. 22, 2018, 11:19 p.m. |
OK |
Java 8 |
TESTS |
176 |
795 |
0 |
|
2400 |
51227846 |
sweiss |
F |
March 12, 2019, 2:52 p.m. |
OK |
Java 8 |
TESTS |
176 |
841 |
0 |
|
2400 |
46104709 |
aabdelzaher |
F |
Nov. 23, 2018, 8:23 a.m. |
OK |
Java 8 |
TESTS |
176 |
841 |
0 |
|
2400 |
46092791 |
peregrinus |
F |
Nov. 22, 2018, 8:27 p.m. |
OK |
Mono C# |
TESTS |
176 |
1356 |
74035200 |
|
2400 |
56796205 |
vjudge3 |
F |
July 10, 2019, 12:37 p.m. |
OK |
MS C++ |
TESTS |
176 |
170 |
0 |
|
2400 |
61397665 |
vjudge4 |
F |
Sept. 28, 2019, 3:22 a.m. |
OK |
MS C++ |
TESTS |
176 |
264 |
0 |
|
2400 |
61423597 |
vjudge2 |
F |
Sept. 28, 2019, 12:30 p.m. |
OK |
MS C++ |
TESTS |
176 |
342 |
0 |
|
2400 |
50701064 |
petko_mitkov |
F |
March 2, 2019, 9:34 p.m. |
OK |
MS C++ 2017 |
TESTS |
176 |
155 |
0 |
|
2400 |
46101401 |
cloudcat111 |
F |
Nov. 23, 2018, 6:08 a.m. |
OK |
Python 3 |
TESTS |
176 |
717 |
921600 |
|
2400 |
46092421 |
cloudcat111 |
F |
Nov. 22, 2018, 8:14 p.m. |
OK |
Python 3 |
TESTS |
176 |
1138 |
921600 |
|
2400 |
46582821 |
JSZX11556 |
F |
Dec. 4, 2018, 11:55 a.m. |
OK |
Python 3 |
TESTS |
176 |
1232 |
3788800 |
|
2400 |
46085628 |
whatshisbucket |
F |
Nov. 22, 2018, 5:31 p.m. |
OK |
Python 3 |
TESTS |
176 |
1294 |
819200 |
|
2400 |
46203593 |
AIshutin |
F |
Nov. 25, 2018, 12:57 p.m. |
OK |
Python 3 |
TESTS |
176 |
1356 |
716800 |
|
2400 |
46582590 |
vjudge3 |
F |
Dec. 4, 2018, 11:50 a.m. |
OK |
Python 3 |
TESTS |
176 |
1372 |
5529600 |
|
2400 |
remove filters
Back to search problems