Codeforces Round 949 (Div. 2)

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
1981 Codeforces Round 949 (Div. 2) FINISHED False 7200 20030063 May 31, 2024, 10:05 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 948 ) E Turtle and Intersected Segments PROGRAMMING data structures ds graphs greedy

B"Turtle just received n segments and a sequence a_1, a_2, ldots, a_n . The i -th segment is [l_i, r_i] . Turtle will create an undirected graph G . If segment i and segment j intersect, then Turtle will add an undirected edge between i and j with a weight of |a_i - a_j| , for every i ne j . Turtle wants you to calculate the sum of the weights of the edges of the minimum spanning tree of the graph G , or report that the graph G has no spanning tree. We say two segments [l_1, r_1] and [l_2, r_2] intersect if and only if max(l_1, l_2) <= min(r_1, r_2) . Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^5 ). The description of the test cases follows. The first line of each test case contains a single integer n ( 2 <= n <= 5 cdot 10^5 ) -- the number of segments. The i -th of the following n lines contains three integers l_i, r_i, a_i ( 1 <= l_i <= r_i <= 10^9, 1 <= a_i <= 10^9 ) -- the i -th segment and the i -th element of the sequence. It is guaranteed that the sum of n over all test cases does not exceed 5 cdot 10^5 . For each test case, output a single integer -- the sum of the weights of the edges of the minimum spanning tree of the graph G . If the graph G has no spanning tree, output -1 . In the first test case, the graph G is as follows: One of the minimum spanning trees of G is as follows: The sum of the weights of the edges of the minimum spanning tree is 9 . In the second test case, the graph G is as follows: G is already a tree, and the sum of the weights of the tree is 13 . In the third test case, the graph G is as follows: In the fourth test case, the graph G is as follows: It's easy to see that G is not connected, so G has no spanning tree. "...

Tutorials

Simplified Chinese Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
263650481 ImmortaLimit E June 1, 2024, 3:38 p.m. OK C++14 (GCC 6-32) TESTS 34 968 55910400
263557803 LG805653 E June 1, 2024, 12:04 a.m. OK C++14 (GCC 6-32) TESTS 34 1140 109260800
263592225 bro_jie E June 1, 2024, 7:32 a.m. OK C++14 (GCC 6-32) TESTS 34 1280 43315200
263576971 cppcppcpp3 E June 1, 2024, 5:15 a.m. OK C++14 (GCC 6-32) TESTS 34 1374 70451200
263576556 cppcppcpp3 E June 1, 2024, 5:10 a.m. OK C++14 (GCC 6-32) TESTS 34 1390 70553600
263696599 EasonLiang E June 2, 2024, 3:54 a.m. OK C++14 (GCC 6-32) TESTS 34 1531 37683200
263504044 H_W_Y E May 31, 2024, 1:21 p.m. OK C++14 (GCC 6-32) TESTS 34 1733 97484800
263618024 yuanzhenxuan E June 1, 2024, 11:04 a.m. OK C++14 (GCC 6-32) TESTS 34 1749 73318400
263505378 zhicheng E May 31, 2024, 1:32 p.m. OK C++14 (GCC 6-32) TESTS 34 1796 39321600
263618749 guoshujin20090423 E June 1, 2024, 11:10 a.m. OK C++14 (GCC 6-32) TESTS 34 1811 253644800
263515991 qwynick E May 31, 2024, 2:59 p.m. OK C++17 (GCC 7-32) TESTS 34 1077 33382400
263514600 qwynick E May 31, 2024, 2:48 p.m. OK C++17 (GCC 7-32) TESTS 34 1171 31232000
263515204 qwynick E May 31, 2024, 2:53 p.m. OK C++17 (GCC 7-32) TESTS 34 1171 33280000
263559461 kookeudas E June 1, 2024, 12:48 a.m. OK C++17 (GCC 7-32) TESTS 34 1249 39116800
263555783 Md._Nahid_Ullah_Joy E May 31, 2024, 11:06 p.m. OK C++17 (GCC 7-32) TESTS 34 1265 35020800
263649727 Khronos_ E June 1, 2024, 3:32 p.m. OK C++17 (GCC 7-32) TESTS 34 1390 32768000
263524257 yasseinhamdy15 E May 31, 2024, 4:11 p.m. OK C++17 (GCC 7-32) TESTS 34 1405 35020800
263621056 Shayan E June 1, 2024, 11:25 a.m. OK C++17 (GCC 7-32) TESTS 34 1405 50585600
263623037 pp_orange E June 1, 2024, 11:41 a.m. OK C++17 (GCC 7-32) TESTS 34 1437 41164800
263517324 fryingduc E May 31, 2024, 3:11 p.m. OK C++17 (GCC 7-32) TESTS 34 1452 46387200
263534134 diobrando97 E May 31, 2024, 5:38 p.m. OK C++20 (GCC 13-64) TESTS 34 1109 45568000
263538141 18o3 E May 31, 2024, 6:15 p.m. OK C++20 (GCC 13-64) TESTS 34 1124 41267200
263644681 liguanghan1 E June 1, 2024, 2:47 p.m. OK C++20 (GCC 13-64) TESTS 34 1140 41267200
263575608 toiday E June 1, 2024, 4:58 a.m. OK C++20 (GCC 13-64) TESTS 34 1171 53862400
263673781 Huangyf E June 1, 2024, 7:09 p.m. OK C++20 (GCC 13-64) TESTS 34 1187 43315200
263601247 tiom4eg E June 1, 2024, 8:47 a.m. OK C++20 (GCC 13-64) TESTS 34 1202 39014400
263639206 liguanghan1 E June 1, 2024, 2 p.m. OK C++20 (GCC 13-64) TESTS 34 1218 41267200
263574972 guagua0407 E June 1, 2024, 4:50 a.m. OK C++20 (GCC 13-64) TESTS 34 1233 47308800
263535730 EJIC_B_KEDAX E May 31, 2024, 5:52 p.m. OK C++20 (GCC 13-64) TESTS 34 1265 55808000
263602892 fanwen E June 1, 2024, 9 a.m. OK C++20 (GCC 13-64) TESTS 34 1296 45260800
263518745 0x3F E May 31, 2024, 3:23 p.m. OK Go TESTS 34 2327 132608000

remove filters

Back to search problems