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'With a problem title like that, there is no way this is going to be a graph problem. Chaneka has a graph with n vertices and n-1 edges. Some of the edges are directed and some of the edges are undirected. Edge i connects vertex u_i to vertex v_i . If t_i=0 , edge i is undirected. If t_i=1 , edge i is directed in the direction from u_i to v_i . It is known that if you make all edges undirected, the graph becomes a tree ^ dagger . Chaneka wants to direct all undirected edges and colour each edge (different edges can have the same colour). After doing that, suppose Chaneka starts a walk from an arbitrary vertex x to an arbitrary vertex y (it is possible that x=y ) going through one or more edges. She is allowed to go through each edge either following the direction or opposite to the direction of the edge. She is also allowed to visit a vertex or an edge more than once. During the walk, Chaneka maintains a stack of balls that is initially empty before the walk. Each time Chaneka goes through an edge, she does the following: A walk is stackable if and only if the stack is not empty before each time Chaneka goes through an edge in the opposite direction. A walk is ball-stackable if and only if it is stackable and each time Chaneka goes through an edge in the opposite direction, the colour of the ball removed from the stack is the same as the colour of the edge traversed. Is it possible to direct all undirected edges and colour each edge such that all stackable walks are also ball-stackable? If it is possible, find a construction example that uses the maximum number of different colours among all valid ways of directing and colouring. If there are multiple such solutions, output any of them. ^ dagger A tree is a connected graph with no cycles. The first line contains a single integer n ( 2 <= q n <= q10^5 ) -- the number of vertices in the graph. The i -th of '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
227260713 |
_Diu_ |
E |
Oct. 9, 2023, 12:24 a.m. |
OK |
GNU C++14 |
TESTS |
58 |
124 |
10547200 |
|
|
227259829 |
_Diu_ |
E |
Oct. 8, 2023, 11:56 p.m. |
OK |
GNU C++14 |
TESTS |
58 |
124 |
10547200 |
|
|
227186766 |
_Diu_ |
E |
Oct. 8, 2023, 11:34 a.m. |
OK |
GNU C++14 |
TESTS |
58 |
140 |
11366400 |
|
|
227219830 |
zhangjianjuncd |
E |
Oct. 8, 2023, 3:42 p.m. |
OK |
GNU C++14 |
TESTS |
58 |
156 |
20684800 |
|
|
227259724 |
yyyyxh |
E |
Oct. 8, 2023, 11:53 p.m. |
OK |
GNU C++14 |
TESTS |
58 |
171 |
7987200 |
|
|
227273737 |
hos.lyric |
E |
Oct. 9, 2023, 4:57 a.m. |
OK |
GNU C++17 |
TESTS |
58 |
202 |
21504000 |
|
|
227253320 |
Sana |
E |
Oct. 8, 2023, 9:03 p.m. |
OK |
GNU C++17 (64) |
TESTS |
58 |
140 |
23040000 |
|
|
227168660 |
kotatsugame |
E |
Oct. 8, 2023, 10:44 a.m. |
OK |
GNU C++17 (64) |
TESTS |
58 |
202 |
44748800 |
|
|
227180728 |
p_b_p_b |
E |
Oct. 8, 2023, 11:18 a.m. |
OK |
GNU C++17 (64) |
TESTS |
58 |
234 |
23756800 |
|
|
227202606 |
244mhq |
E |
Oct. 8, 2023, 1:41 p.m. |
OK |
GNU C++17 (64) |
TESTS |
58 |
248 |
43008000 |
|
|
227264400 |
grass8sheep |
E |
Oct. 9, 2023, 1:58 a.m. |
OK |
GNU C++17 (64) |
TESTS |
58 |
296 |
24678400 |
|
|
227274018 |
tricyzhkx |
E |
Oct. 9, 2023, 5:01 a.m. |
OK |
GNU C++17 (64) |
TESTS |
58 |
342 |
23142400 |
|
|
227181408 |
heno239 |
E |
Oct. 8, 2023, 11:20 a.m. |
OK |
GNU C++17 (64) |
TESTS |
58 |
374 |
65126400 |
|
|
227254961 |
chappy1 |
E |
Oct. 8, 2023, 9:35 p.m. |
OK |
GNU C++17 (64) |
TESTS |
58 |
436 |
41472000 |
|
|
227229680 |
tute7627 |
E |
Oct. 8, 2023, 5:01 p.m. |
OK |
GNU C++17 (64) |
TESTS |
58 |
436 |
83046400 |
|
|
227180790 |
dlalswp25 |
E |
Oct. 8, 2023, 11:19 a.m. |
OK |
GNU C++17 (64) |
TESTS |
58 |
483 |
41472000 |
|
|
227174767 |
xukai |
E |
Oct. 8, 2023, 11:01 a.m. |
OK |
GNU C++20 (64) |
TESTS |
58 |
109 |
18227200 |
|
|
227265432 |
A_G |
E |
Oct. 9, 2023, 2:22 a.m. |
OK |
GNU C++20 (64) |
TESTS |
58 |
124 |
21811200 |
|
|
227261034 |
A_G |
E |
Oct. 9, 2023, 12:33 a.m. |
OK |
GNU C++20 (64) |
TESTS |
58 |
124 |
21811200 |
|
|
227208869 |
huangpj |
E |
Oct. 8, 2023, 2:26 p.m. |
OK |
GNU C++20 (64) |
TESTS |
58 |
155 |
15667200 |
|
|
227172380 |
jiangly |
E |
Oct. 8, 2023, 10:54 a.m. |
OK |
GNU C++20 (64) |
TESTS |
58 |
171 |
15667200 |
|
|
227170474 |
ksun48 |
E |
Oct. 8, 2023, 10:49 a.m. |
OK |
GNU C++20 (64) |
TESTS |
58 |
202 |
24883200 |
|
|
227196386 |
nguyenquocthinhhung |
E |
Oct. 8, 2023, 1:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
58 |
202 |
43315200 |
|
|
227151734 |
maroonrk |
E |
Oct. 8, 2023, 10:06 a.m. |
OK |
GNU C++20 (64) |
TESTS |
58 |
202 |
43315200 |
|
|
227261390 |
AI_COre |
E |
Oct. 9, 2023, 12:43 a.m. |
OK |
GNU C++20 (64) |
TESTS |
58 |
234 |
34508800 |
|
|
227267042 |
RNS_KSR |
E |
Oct. 9, 2023, 2:58 a.m. |
OK |
GNU C++20 (64) |
TESTS |
58 |
296 |
25907200 |
|
|
remove filters
Back to search problems