Codeforces Round 366 (Div. 1)

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
704 Codeforces Round 366 (Div. 1) FINISHED False 7200 305826923 Aug. 7, 2016, 2:05 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 347 ) E Iron Man PROGRAMMING data structures geometry trees 3500

Tony Stark is playing a game with his suits (they have auto-pilot now). He lives in Malibu. Malibu has n junctions numbered from 1 to n , connected with n - 1 roads. One can get from a junction to any other junction using these roads (graph of Malibu forms a tree). Tony has m suits. There's a special plan for each suit. The i -th suit will appear at the moment of time t i in the junction v i , and will move to junction u i using the shortest path between v i and u i with the speed c i roads per second (passing a junctions takes no time), and vanishing immediately when arriving at u i (if it reaches u i in time q , it's available there at moment q , but not in further moments). Also, suits move continuously (for example if v i ≠ u i , at time it's in the middle of a road. Please note that if v i = u i it means the suit will be at junction number v i only at moment t i and then it vanishes. An explosion happens if at any moment of time two suits share the same exact location (it may be in a junction or somewhere on a road; while appearing, vanishing or moving). Your task is to tell Tony the moment of the the first explosion (if there will be any). The first line of the input contains two integers n and m ( 1 ≤ n , m ≤ 100 000 ) — the number of junctions and the number of suits respectively. The next n - 1 lines contain the roads descriptions. Each line contains two integers a i and b i — endpoints of the i -th road ( 1 ≤ a i , b i ≤ n , a i ≠ b i ). The next m lines contain the suit descriptions. The i -th of them contains four integers t i , c i , v i and u i ( 0 ≤ t i ≤ 10 000, 1 ≤ c i ≤ 10 000 , 1 ≤ v i , u i ≤ n ), meaning the i -th suit will appear at moment of time t i at the junction v i and will move to the junction u i with a speed c i roads per second. If there would be no explosions at all, print -1 in the first and only line of output. Otherwise print the moment of the first explosion. Your answer will be considered correct if its relative or abs

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
19897825 fzfzfz E Aug. 16, 2016, 1:19 a.m. OK GNU C++ TESTS 99 296 138342400 3500
36618982 vjudge4 E March 25, 2018, 2:05 p.m. OK GNU C++ TESTS 99 296 139776000 3500
28380680 unkito E July 9, 2017, 4:58 a.m. OK GNU C++ TESTS 99 326 61952000 3500
28388251 vjudge2 E July 9, 2017, 1:32 p.m. OK GNU C++ TESTS 99 358 56729600 3500
28388227 vjudge4 E July 9, 2017, 1:30 p.m. OK GNU C++ TESTS 99 358 56729600 3500
28388332 vjudge2 E July 9, 2017, 1:36 p.m. OK GNU C++ TESTS 99 358 56832000 3500
28380586 unkito E July 9, 2017, 4:49 a.m. OK GNU C++ TESTS 99 358 56832000 3500
28379017 vjudge1 E July 9, 2017, 2:27 a.m. OK GNU C++ TESTS 99 358 61849600 3500
28388243 vjudge2 E July 9, 2017, 1:31 p.m. OK GNU C++ TESTS 99 373 56729600 3500
28408032 vjudge1 E July 10, 2017, 1:11 p.m. OK GNU C++ TESTS 99 374 56729600 3500
55967431 suchang E June 23, 2019, 12:55 p.m. OK GNU C++11 TESTS 99 202 52428800 3500
55998959 Miracle_2001 E June 24, 2019, 12:03 p.m. OK GNU C++11 TESTS 99 217 44032000 3500
58116883 luogu_bot2 E Aug. 1, 2019, 9:10 a.m. OK GNU C++11 TESTS 99 233 43929600 3500
55998914 Miracle_2001 E June 24, 2019, 12:02 p.m. OK GNU C++11 TESTS 99 248 44032000 3500
58226195 lzoilxy E Aug. 3, 2019, 2:34 p.m. OK GNU C++11 TESTS 99 248 54374400 3500
58227139 daydream. E Aug. 3, 2019, 2:58 p.m. OK GNU C++11 TESTS 99 249 54374400 3500
65327108 zx2003 E Nov. 19, 2019, 2:41 a.m. OK GNU C++11 TESTS 99 280 56729600 3500
64524552 WZYYN E Nov. 8, 2019, 1:22 p.m. OK GNU C++11 TESTS 99 280 57139200 3500
51246096 tumoyakov E March 13, 2019, 5:19 a.m. OK GNU C++11 TESTS 99 280 59904000 3500
19974940 Scayre E Aug. 20, 2016, 4:42 a.m. OK GNU C++11 TESTS 99 280 138342400 3500
69164621 weng_233 E Jan. 20, 2020, 2:51 a.m. OK GNU C++14 TESTS 99 311 42905600 3500
57479201 Scut82 E July 22, 2019, 1:21 a.m. OK GNU C++14 TESTS 99 327 48025600 3500
52379861 Sunflash E April 6, 2019, 9:39 a.m. OK GNU C++14 TESTS 99 343 136192000 3500
61761427 luogu_bot3 E Oct. 3, 2019, 7:14 a.m. OK GNU C++14 TESTS 99 373 44134400 3500
58174967 yhdd E Aug. 2, 2019, 12:43 p.m. OK GNU C++14 TESTS 99 373 44134400 3500
24362308 Wolf_Man E Feb. 2, 2017, 11:04 a.m. OK GNU C++14 TESTS 99 405 138137600 3500
69223670 mrsrz E Jan. 21, 2020, 6:08 a.m. OK GNU C++14 TESTS 99 421 130048000 3500
50471648 littlefan E Feb. 25, 2019, 1:28 a.m. OK GNU C++14 TESTS 99 467 43315200 3500
50471217 littlefan E Feb. 25, 2019, 12:51 a.m. OK GNU C++14 TESTS 99 467 43315200 3500
55864960 Wearry E June 21, 2019, 11:37 a.m. OK GNU C++14 TESTS 99 467 96256000 3500
65587477 HirasawaaYui E Nov. 23, 2019, 12:57 p.m. OK GNU C++17 TESTS 99 358 94310400 3500
62677638 gongsuidashen E Oct. 16, 2019, 11:53 a.m. OK GNU C++17 TESTS 99 374 44134400 3500
49684783 pandora_lee E Feb. 10, 2019, 6:19 a.m. OK GNU C++17 TESTS 99 390 87859200 3500
69591225 vjudge3 E Jan. 26, 2020, 11:44 p.m. OK GNU C++17 TESTS 99 499 87756800 3500
69575587 vjudge1 E Jan. 26, 2020, 3:27 p.m. OK GNU C++17 TESTS 99 530 43315200 3500
55969435 jah_melon E June 23, 2019, 1:56 p.m. OK GNU C++17 TESTS 99 655 96870400 3500
52675057 jah_melon E April 13, 2019, 9:11 a.m. OK GNU C++17 TESTS 99 670 96870400 3500
57605118 Benq E July 23, 2019, 5:32 p.m. OK GNU C++17 TESTS 99 670 106291200 3500
52675210 jah_melon E April 13, 2019, 9:16 a.m. OK GNU C++17 TESTS 99 685 96972800 3500
64340902 vjudge4 E Nov. 6, 2019, 2:37 a.m. OK GNU C++17 TESTS 99 686 76595200 3500
19919505 Los_Angelos_Laycurse E Aug. 17, 2016, 4:37 a.m. OK MS C++ TESTS 99 327 24371200 3500
19919493 Los_Angelos_Laycurse E Aug. 17, 2016, 4:36 a.m. OK MS C++ TESTS 99 374 24371200 3500
19903387 Los_Angelos_Laycurse E Aug. 16, 2016, 8:45 a.m. OK MS C++ TESTS 99 577 24371200 3500
19903335 Los_Angelos_Laycurse E Aug. 16, 2016, 8:41 a.m. OK MS C++ TESTS 99 577 24371200 3500
19903396 Los_Angelos_Laycurse E Aug. 16, 2016, 8:45 a.m. OK MS C++ TESTS 99 592 24371200 3500
19903351 Los_Angelos_Laycurse E Aug. 16, 2016, 8:42 a.m. OK MS C++ TESTS 99 592 24371200 3500

remove filters

Back to search problems