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'There are n cities in Treeland connected with n - 1 bidirectional roads in such that a way that any city is reachable from any other; in other words, the graph of cities and roads is a tree. Treeland is preparing for a seasonal virus epidemic, and currently, they are trying to evaluate different infection scenarios. In each scenario, several cities are initially infected with different virus species. Suppose that there are k_i virus species in the i -th scenario. Let us denote v_j the initial city for the virus j , and s_j the propagation speed of the virus j . The spread of the viruses happens in turns: first virus 1 spreads, followed by virus 2 , and so on. After virus k_i spreads, the process starts again from virus 1 . A spread turn of virus j proceeds as follows. For each city x not infected with any virus at the start of the turn, at the end of the turn it becomes infected with virus j if and only if there is such a city y that: Once a city is infected with a virus, it stays infected indefinitely and can not be infected with any other virus. The spread stops once all cities are infected. You need to process q independent scenarios. Each scenario is described by k_i virus species and m_i important cities. For each important city determine which the virus it will be infected by in the end. The first line contains a single integer n ( 1 <= q n <= q 2 cdot 10^5 ) -- the number of cities in Treeland. The following n - 1 lines describe the roads. The i -th of these lines contains two integers x_i and y_i ( 1 <= q x_i, y_i <= q n ) -- indices of cities connecting by the i -th road. It is guaranteed that the given graph of cities and roads is a tree. The next line contains a single integer q ( 1 <= q q <= q 2 cdot 10^5 ) -- the number of infection scenarios. q scenario descriptions foll'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
72200502 |
Lagoon_ |
E |
March 1, 2020, 3:07 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
343 |
68198400 |
|
|
72197732 |
Itst |
E |
March 1, 2020, 2:56 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
404 |
34508800 |
|
|
72194782 |
cjy2003 |
E |
March 1, 2020, 2:43 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
499 |
35532800 |
|
|
72195289 |
WZYYN |
E |
March 1, 2020, 2:45 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
499 |
35737600 |
|
|
72207421 |
wzp666 |
E |
March 1, 2020, 5:10 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
514 |
44851200 |
|
|
72198992 |
EricHuang2003 |
E |
March 1, 2020, 3:01 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
545 |
46796800 |
|
|
72198569 |
CrescentRose |
E |
March 1, 2020, 2:59 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
655 |
38195200 |
|
|
72201233 |
cuizhuyefei |
E |
March 1, 2020, 3:10 p.m. |
OK |
GNU C++11 |
TESTS |
28 |
966 |
89804800 |
|
|
72191679 |
jijiang |
E |
March 1, 2020, 2:30 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
483 |
60416000 |
|
|
72216889 |
Devil |
E |
March 1, 2020, 8:50 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
576 |
66969600 |
|
|
72216802 |
Devil |
E |
March 1, 2020, 8:47 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
592 |
67072000 |
|
|
72217016 |
Devil |
E |
March 1, 2020, 8:54 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
608 |
66969600 |
|
|
72196864 |
Jayce132 |
E |
March 1, 2020, 2:52 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
639 |
93900800 |
|
|
72216987 |
Devil |
E |
March 1, 2020, 8:53 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
702 |
66969600 |
|
|
72200348 |
lllllllllllllllllllllll |
E |
March 1, 2020, 3:07 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
733 |
46080000 |
|
|
72206611 |
Nson |
E |
March 1, 2020, 4:56 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
779 |
122265600 |
|
|
72206761 |
Nson |
E |
March 1, 2020, 4:58 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
794 |
78950400 |
|
|
72211844 |
860579 |
E |
March 1, 2020, 6:41 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
795 |
74956800 |
|
|
72195901 |
skip2004 |
E |
March 1, 2020, 2:48 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
546 |
37376000 |
|
|
72206856 |
wooookje |
E |
March 1, 2020, 5 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
561 |
44236800 |
|
|
72200353 |
aid |
E |
March 1, 2020, 3:07 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
576 |
39628800 |
|
|
72207304 |
neal |
E |
March 1, 2020, 5:08 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
654 |
65843200 |
|
|
72205904 |
neal |
E |
March 1, 2020, 4:45 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
655 |
65843200 |
|
|
72192473 |
Radewoosh |
E |
March 1, 2020, 2:33 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
655 |
82944000 |
|
|
72200456 |
gtrhetr |
E |
March 1, 2020, 3:07 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
685 |
45260800 |
|
|
72204965 |
chemthan |
E |
March 1, 2020, 4:35 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
685 |
59494400 |
|
|
72207256 |
Benq |
E |
March 1, 2020, 5:07 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
685 |
69120000 |
|
|
72207354 |
Benq |
E |
March 1, 2020, 5:09 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
686 |
69120000 |
|
|
72205711 |
cwise |
E |
March 1, 2020, 4:42 p.m. |
OK |
Java 8 |
TESTS |
28 |
1497 |
200908800 |
|
|
remove filters
Back to search problems