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'Uncle Bogdan is in captain Flint 's crew for a long time and sometimes gets nostalgic for his homeland. Today he told you how his country introduced a happiness index. There are n cities and n xe2 x88 x921 undirected roads connecting pairs of cities. Citizens of any city can reach any other city traveling by these roads. Cities are numbered from 1 to n and the city 1 is a capital. In other words, the country has a tree structure. There are m citizens living in the country. A p_i people live in the i -th city but all of them are working in the capital. At evening all citizens return to their home cities using the shortest paths. Every person has its own mood: somebody leaves his workplace in good mood but somebody are already in bad mood. Moreover any person can ruin his mood on the way to the hometown. If person is in bad mood he won 't improve it. Happiness detectors are installed in each city to monitor the happiness of each person who visits the city. The detector in the i -th city calculates a happiness index h_i as the number of people in good mood minus the number of people in bad mood. Let 's say for the simplicity that mood of a person doesn 't change inside the city. Happiness detector is still in development, so there is a probability of a mistake in judging a person 's happiness. One late evening, when all citizens successfully returned home, the government asked uncle Bogdan (the best programmer of the country) to check the correctness of the collected happiness indexes. Uncle Bogdan successfully solved the problem. Can you do the same? More formally, You need to check: "Is it possible that, after all people return home, for each city i the happiness index will be equal exactly to h_i ". The first line contains a single integer t ( 1 <= t <= 10000 ) -- the number of test cases. The first line of each test case contains two integers n and m ( 1 <= n <= 10^5 ;'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
88770960 |
dyxx |
C |
Aug. 3, 2020, 4:15 a.m. |
OK |
GNU C11 |
TESTS |
46 |
139 |
7577600 |
|
1800 |
91639660 |
luogu_bot2 |
C |
Sept. 2, 2020, 12:22 p.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
5939200 |
|
1800 |
91639507 |
hjh |
C |
Sept. 2, 2020, 12:20 p.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
5939200 |
|
1800 |
89763620 |
S-X-Y |
C |
Aug. 13, 2020, 5:46 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
6656000 |
|
1800 |
89541157 |
Dzhao |
C |
Aug. 11, 2020, 1:09 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
7372800 |
|
1800 |
88771422 |
zuoruiping |
C |
Aug. 3, 2020, 4:29 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
7782400 |
|
1800 |
89546516 |
jiuruifu |
C |
Aug. 11, 2020, 4:06 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
7884800 |
|
1800 |
89839181 |
luogu_bot4 |
C |
Aug. 14, 2020, 3:59 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
8294400 |
|
1800 |
89542254 |
Scarlet_Hypoc |
C |
Aug. 11, 2020, 1:55 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
9420800 |
|
1800 |
88882267 |
SGColin |
C |
Aug. 4, 2020, 3:02 p.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
12083200 |
|
1800 |
89500903 |
Oak_limy |
C |
Aug. 10, 2020, 10:29 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
12492800 |
|
1800 |
88730823 |
king17pvp |
C |
Aug. 2, 2020, 12:30 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
155 |
9728000 |
|
1800 |
91257596 |
Swarn10 |
C |
Aug. 29, 2020, 5:24 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
171 |
5939200 |
|
1800 |
91114470 |
THEphantom |
C |
Aug. 27, 2020, 7:59 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
171 |
6041600 |
|
1800 |
90412560 |
toxicviper |
C |
Aug. 19, 2020, 6:02 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
171 |
8396800 |
|
1800 |
89479292 |
SebasV8 |
C |
Aug. 10, 2020, 4:36 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
171 |
9318400 |
|
1800 |
88933046 |
Rohitmakkar |
C |
Aug. 5, 2020, 9:35 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
171 |
9728000 |
|
1800 |
88853445 |
clarkent |
C |
Aug. 4, 2020, 8:16 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
171 |
9728000 |
|
1800 |
88742596 |
yanyanlongxia |
C |
Aug. 2, 2020, 3:23 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
171 |
9728000 |
|
1800 |
89551614 |
Karthee |
C |
Aug. 11, 2020, 5:53 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
171 |
9728000 |
|
1800 |
90717826 |
idontreallyknow |
C |
Aug. 22, 2020, 9:42 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
171 |
10035200 |
|
1800 |
88865430 |
Trisolaris |
C |
Aug. 4, 2020, 11:14 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
78 |
6963200 |
|
1800 |
89796759 |
Clouder0 |
C |
Aug. 13, 2020, 1:12 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
93 |
8396800 |
|
1800 |
89079258 |
jintiandun |
C |
Aug. 6, 2020, 1:53 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
140 |
12800000 |
|
1800 |
89079320 |
jintiandun |
C |
Aug. 6, 2020, 1:55 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
140 |
13004800 |
|
1800 |
89278337 |
kinssang |
C |
Aug. 7, 2020, 5:04 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
156 |
11264000 |
|
1800 |
88851758 |
ashk_21 |
C |
Aug. 4, 2020, 7:52 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
170 |
9728000 |
|
1800 |
89768650 |
epidemic |
C |
Aug. 13, 2020, 6:59 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
171 |
5939200 |
|
1800 |
90027888 |
forceac |
C |
Aug. 15, 2020, 2:55 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
171 |
5939200 |
|
1800 |
88754413 |
Roka |
C |
Aug. 2, 2020, 6:23 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
171 |
8908800 |
|
1800 |
89545284 |
arnav7060 |
C |
Aug. 11, 2020, 3:31 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
171 |
9728000 |
|
1800 |
88802746 |
...._.._ |
C |
Aug. 3, 2020, 1:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
93 |
11366400 |
|
1800 |
88803187 |
...._.._ |
C |
Aug. 3, 2020, 1:37 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
108 |
11776000 |
|
1800 |
89828153 |
vjudge3 |
C |
Aug. 13, 2020, 9:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
155 |
7475200 |
|
1800 |
90364012 |
adi2710 |
C |
Aug. 19, 2020, 6:42 a.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
155 |
10752000 |
|
1800 |
89195007 |
not_slacker |
C |
Aug. 7, 2020, 10:12 a.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
155 |
10854400 |
|
1800 |
88871534 |
alexradu04 |
C |
Aug. 4, 2020, 12:52 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
155 |
10956800 |
|
1800 |
89491625 |
sharrad99 |
C |
Aug. 10, 2020, 7:59 a.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
155 |
11161600 |
|
1800 |
88896348 |
akas.06032000 |
C |
Aug. 4, 2020, 6:21 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
155 |
11776000 |
|
1800 |
89515340 |
iaNTU |
C |
Aug. 10, 2020, 1:55 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
155 |
12390400 |
|
1800 |
89195571 |
vjudge3 |
C |
Aug. 7, 2020, 10:21 a.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
155 |
13414400 |
|
1800 |
88796963 |
SevenDeadlySins |
C |
Aug. 3, 2020, 12:16 p.m. |
OK |
Java 11 |
TESTS |
46 |
436 |
38400000 |
|
1800 |
89168767 |
jay_vish |
C |
Aug. 7, 2020, 3:07 a.m. |
OK |
Java 11 |
TESTS |
46 |
483 |
62156800 |
|
1800 |
88798235 |
jayesh_patil |
C |
Aug. 3, 2020, 12:32 p.m. |
OK |
Java 11 |
TESTS |
46 |
529 |
46899200 |
|
1800 |
88823300 |
sam_abbas80 |
C |
Aug. 3, 2020, 6:36 p.m. |
OK |
Java 11 |
TESTS |
46 |
529 |
48025600 |
|
1800 |
88877146 |
anshum_it_is |
C |
Aug. 4, 2020, 2 p.m. |
OK |
Java 11 |
TESTS |
46 |
529 |
50585600 |
|
1800 |
88823339 |
sam_abbas80 |
C |
Aug. 3, 2020, 6:36 p.m. |
OK |
Java 11 |
TESTS |
46 |
560 |
48025600 |
|
1800 |
88934711 |
Witless_Deer |
C |
Aug. 5, 2020, 9:59 a.m. |
OK |
Java 11 |
TESTS |
46 |
561 |
48435200 |
|
1800 |
89855534 |
glider.g |
C |
Aug. 14, 2020, 8:49 a.m. |
OK |
Java 11 |
TESTS |
46 |
576 |
22425600 |
|
1800 |
88920250 |
naval19065 |
C |
Aug. 5, 2020, 6:13 a.m. |
OK |
Java 11 |
TESTS |
46 |
577 |
46489600 |
|
1800 |
90374580 |
yashkundu |
C |
Aug. 19, 2020, 9:15 a.m. |
OK |
Java 11 |
TESTS |
46 |
592 |
20172800 |
|
1800 |
90285310 |
chesiver |
C |
Aug. 18, 2020, 7:20 a.m. |
OK |
Java 8 |
TESTS |
46 |
248 |
921600 |
|
1800 |
90285357 |
chesiver |
C |
Aug. 18, 2020, 7:20 a.m. |
OK |
Java 8 |
TESTS |
46 |
264 |
819200 |
|
1800 |
90198760 |
amolpratap007 |
C |
Aug. 17, 2020, 6:08 a.m. |
OK |
Java 8 |
TESTS |
46 |
280 |
19353600 |
|
1800 |
91597908 |
partizan22 |
C |
Sept. 1, 2020, 8:17 p.m. |
OK |
Java 8 |
TESTS |
46 |
296 |
3379200 |
|
1800 |
88823270 |
revanthreddy85 |
C |
Aug. 3, 2020, 6:35 p.m. |
OK |
Java 8 |
TESTS |
46 |
327 |
43724800 |
|
1800 |
90487173 |
MubtasimShahriar |
C |
Aug. 20, 2020, 5:54 p.m. |
OK |
Java 8 |
TESTS |
46 |
358 |
19968000 |
|
1800 |
88935800 |
hulk_man |
C |
Aug. 5, 2020, 10:16 a.m. |
OK |
Java 8 |
TESTS |
46 |
405 |
40857600 |
|
1800 |
88795127 |
wangzuo |
C |
Aug. 3, 2020, 11:49 a.m. |
OK |
Java 8 |
TESTS |
46 |
451 |
48844800 |
|
1800 |
88799013 |
kalzor |
C |
Aug. 3, 2020, 12:42 p.m. |
OK |
Java 8 |
TESTS |
46 |
452 |
38092800 |
|
1800 |
88821066 |
godxpunk |
C |
Aug. 3, 2020, 5:54 p.m. |
OK |
Java 8 |
TESTS |
46 |
452 |
45158400 |
|
1800 |
88870097 |
wuchaojie925 |
C |
Aug. 4, 2020, 12:34 p.m. |
OK |
Kotlin |
TESTS |
46 |
624 |
39936000 |
|
1800 |
88869761 |
wuchaojie925 |
C |
Aug. 4, 2020, 12:29 p.m. |
OK |
Kotlin |
TESTS |
46 |
624 |
42086400 |
|
1800 |
88866171 |
wuchaojie925 |
C |
Aug. 4, 2020, 11:24 a.m. |
OK |
Kotlin |
TESTS |
46 |
654 |
40038400 |
|
1800 |
88865909 |
wuchaojie925 |
C |
Aug. 4, 2020, 11:21 a.m. |
OK |
Kotlin |
TESTS |
46 |
701 |
40038400 |
|
1800 |
88745636 |
Mosyagin |
C |
Aug. 2, 2020, 4:03 p.m. |
OK |
Mono C# |
TESTS |
46 |
452 |
36864000 |
|
1800 |
89842294 |
azukun |
C |
Aug. 14, 2020, 5:08 a.m. |
OK |
Mono C# |
TESTS |
46 |
826 |
169779200 |
|
1800 |
89117199 |
vjudge1 |
C |
Aug. 6, 2020, 11:54 a.m. |
OK |
MS C++ |
TESTS |
46 |
514 |
10035200 |
|
1800 |
89101494 |
vjudge3 |
C |
Aug. 6, 2020, 8:26 a.m. |
OK |
MS C++ |
TESTS |
46 |
514 |
10240000 |
|
1800 |
89100448 |
vjudge2 |
C |
Aug. 6, 2020, 8:11 a.m. |
OK |
MS C++ |
TESTS |
46 |
530 |
10035200 |
|
1800 |
88989407 |
vjudge1 |
C |
Aug. 5, 2020, 3 p.m. |
OK |
MS C++ |
TESTS |
46 |
546 |
38809600 |
|
1800 |
89484380 |
vjudge1 |
C |
Aug. 10, 2020, 6:11 a.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
218 |
9932800 |
|
1800 |
88758830 |
AleksanderBalobanov |
C |
Aug. 2, 2020, 8:09 p.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
233 |
15052800 |
|
1800 |
90455599 |
exode4 |
C |
Aug. 20, 2020, 10:54 a.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
265 |
5734400 |
|
1800 |
89755651 |
dixmw34 |
C |
Aug. 13, 2020, 3:15 a.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
546 |
5734400 |
|
1800 |
90287972 |
dixmw34 |
C |
Aug. 18, 2020, 7:56 a.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
561 |
5734400 |
|
1800 |
88776978 |
rhksdn6227 |
C |
Aug. 3, 2020, 6:40 a.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
577 |
10547200 |
|
1800 |
88759685 |
prosto_user |
C |
Aug. 2, 2020, 8:33 p.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
592 |
23552000 |
|
1800 |
88780677 |
anirudhgupta0510 |
C |
Aug. 3, 2020, 7:44 a.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
607 |
9420800 |
|
1800 |
88780861 |
anirudhgupta0510 |
C |
Aug. 3, 2020, 7:47 a.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
624 |
9420800 |
|
1800 |
89336796 |
Prokopiy |
C |
Aug. 8, 2020, 1:11 p.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
639 |
8499200 |
|
1800 |
89634023 |
yumtam |
C |
Aug. 12, 2020, 8:21 a.m. |
OK |
PyPy 2 |
TESTS |
46 |
420 |
58572800 |
|
1800 |
89340007 |
beethoven97 |
C |
Aug. 8, 2020, 1:55 p.m. |
OK |
PyPy 2 |
TESTS |
46 |
919 |
60723200 |
|
1800 |
89290431 |
shadoX |
C |
Aug. 7, 2020, 8:27 p.m. |
OK |
PyPy 3 |
TESTS |
46 |
545 |
46694400 |
|
1800 |
89756063 |
cybertron1609 |
C |
Aug. 13, 2020, 3:24 a.m. |
OK |
PyPy 3 |
TESTS |
46 |
545 |
49766400 |
|
1800 |
89863928 |
govindsaj |
C |
Aug. 14, 2020, 10:59 a.m. |
OK |
PyPy 3 |
TESTS |
46 |
545 |
58572800 |
|
1800 |
91091369 |
sajad.n |
C |
Aug. 26, 2020, 9:15 p.m. |
OK |
PyPy 3 |
TESTS |
46 |
592 |
29491200 |
|
1800 |
89290549 |
shadoX |
C |
Aug. 7, 2020, 8:30 p.m. |
OK |
PyPy 3 |
TESTS |
46 |
608 |
54784000 |
|
1800 |
91087591 |
sajad.n |
C |
Aug. 26, 2020, 7:38 p.m. |
OK |
PyPy 3 |
TESTS |
46 |
655 |
29286400 |
|
1800 |
88783923 |
DeepBorys |
C |
Aug. 3, 2020, 8:39 a.m. |
OK |
PyPy 3 |
TESTS |
46 |
935 |
68710400 |
|
1800 |
91587198 |
Tomii9273 |
C |
Sept. 1, 2020, 5:06 p.m. |
OK |
PyPy 3 |
TESTS |
46 |
1029 |
51814400 |
|
1800 |
88891852 |
devesh1102 |
C |
Aug. 4, 2020, 5:12 p.m. |
OK |
PyPy 3 |
TESTS |
46 |
1138 |
70553600 |
|
1800 |
88736304 |
funywoohoo |
C |
Aug. 2, 2020, 1:56 p.m. |
OK |
PyPy 3 |
TESTS |
46 |
1262 |
62054400 |
|
1800 |
88757819 |
BlackBook9406 |
C |
Aug. 2, 2020, 7:42 p.m. |
OK |
Python 3 |
TESTS |
46 |
920 |
27340800 |
|
1800 |
88802022 |
eugalt |
C |
Aug. 3, 2020, 1:22 p.m. |
OK |
Python 3 |
TESTS |
46 |
982 |
26726400 |
|
1800 |
89517110 |
nowrin_brown |
C |
Aug. 10, 2020, 2:17 p.m. |
OK |
Python 3 |
TESTS |
46 |
982 |
26828800 |
|
1800 |
88951848 |
eugalt |
C |
Aug. 5, 2020, 1:50 p.m. |
OK |
Python 3 |
TESTS |
46 |
997 |
26624000 |
|
1800 |
88933360 |
Nifer |
C |
Aug. 5, 2020, 9:40 a.m. |
OK |
Python 3 |
TESTS |
46 |
998 |
26624000 |
|
1800 |
88951705 |
eugalt |
C |
Aug. 5, 2020, 1:49 p.m. |
OK |
Python 3 |
TESTS |
46 |
1029 |
26624000 |
|
1800 |
88927207 |
janardhan_6635 |
C |
Aug. 5, 2020, 8:04 a.m. |
OK |
Python 3 |
TESTS |
46 |
1060 |
25907200 |
|
1800 |
88806425 |
eugalt |
C |
Aug. 3, 2020, 2:17 p.m. |
OK |
Python 3 |
TESTS |
46 |
1060 |
26828800 |
|
1800 |
88927044 |
janardhan_6635 |
C |
Aug. 5, 2020, 8:02 a.m. |
OK |
Python 3 |
TESTS |
46 |
1076 |
26112000 |
|
1800 |
89981586 |
wisest |
C |
Aug. 15, 2020, 2:45 a.m. |
OK |
Python 3 |
TESTS |
46 |
1091 |
23244800 |
|
1800 |
89151185 |
SteelRaven |
C |
Aug. 6, 2020, 6:26 p.m. |
OK |
Rust |
TESTS |
46 |
124 |
8499200 |
|
1800 |
88877138 |
Strorkis |
C |
Aug. 4, 2020, 2 p.m. |
OK |
Rust |
TESTS |
46 |
155 |
9830400 |
|
1800 |
89519566 |
dataisland |
C |
Aug. 10, 2020, 2:49 p.m. |
OK |
Rust |
TESTS |
46 |
233 |
9625600 |
|
1800 |
90039022 |
n1tz53 |
C |
Aug. 15, 2020, 5:55 p.m. |
OK |
Rust |
TESTS |
46 |
280 |
9216000 |
|
1800 |
90036982 |
n1tz53 |
C |
Aug. 15, 2020, 5:14 p.m. |
OK |
Rust |
TESTS |
46 |
296 |
9011200 |
|
1800 |
89634576 |
terraformer |
C |
Aug. 12, 2020, 8:30 a.m. |
OK |
Rust |
TESTS |
46 |
732 |
15360000 |
|
1800 |
remove filters
Back to search problems