Codeforces Round 1039 (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
2128 Codeforces Round 1039 (Div. 2) FINISHED False 7200 22778723 July 27, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 377 ) F Strict Triangle PROGRAMMING graphs shortest paths

You are given an undirected connected graph with (n) nodes and (m) edges. The weight (w_i) of the (i)-th edge is not yet decided and must be a real number between (l_i) and (r_i). You are given a node (k). Determine if there exists a valid assignment of weights ((w_1, \ldots, w_m)) such that: (l_i \leq w_i \leq r_i) for all (i), and (\mathrm{dist}_w(1, n) \neq \mathrm{dist}_w(1, k) + \mathrm{dist}_w(k, n))(^{\text{∗}}). (^{\text{∗}})Given an assignment of weights (w), (\mathrm{dist}_w(u, v)) is the minimum value of (w_{e_1} + w_{e_2} + \ldots + w_{e_p}) over all sequences of (p) edges ((e_1, e_2, \ldots, e_p)) that form a path from (u) to (v). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10\,000)). The description of the test cases follows. The first line of each test case contains three integers (n), (m), and (k) ((4 \le n \le 200\,000), (n-1 \le m \le 200\,000), (2 \le k \le n - 1)) — the number of nodes, the number of edges, and the node (k). The (i)-th of the following (m) lines contains four integers (u_i), (v_i), (l_i), and (r_i) ((1 \le u_i, v_i \le n), (u_i \ne v_i), (1 \le l_i \le r_i \le 10^9)), representing an edge between (u_i) and (v_i) whose weight must be between (l_i) and (r_i) inclusive. No edge appears in the input more than once. It is guaranteed that: the sum of (n) over all test cases doesn't exceed (200\,000) the sum of (m) over all test cases doesn't exceed (200\,000) Print YES if there exists a valid assignment of weights and NO otherwise. You can output the answer in any case (upper or lower). For example, the strings " yEs ", " yes ", " Yes ", and " YES " will be recognized as positive responses. In the first test case, (w = (20, 30, 49, 21)) is a valid assignment of weights, since $$$

Tutorials

Codeforces Round #1039 — Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
331213582 ilija_IR_13 F July 27, 2025, 8:39 p.m. OK C++17 (GCC 7-32) TESTS 23 312 22323200
331221073 Tomato_Cultivator F July 27, 2025, 11:01 p.m. OK C++17 (GCC 7-32) TESTS 23 421 11161600
331214061 eric574 F July 27, 2025, 8:45 p.m. OK C++20 (GCC 13-64) TESTS 23 281 15155200
331228311 Egg_laying_master F July 28, 2025, 1:22 a.m. OK C++20 (GCC 13-64) TESTS 23 281 27852800
331223045 TataneSan F July 27, 2025, 11:52 p.m. OK C++20 (GCC 13-64) TESTS 23 296 16179200
331211132 Kerw1l F July 27, 2025, 8:08 p.m. OK C++20 (GCC 13-64) TESTS 23 296 20377600
331198575 bestial-42-centroids F July 27, 2025, 6:01 p.m. OK C++20 (GCC 13-64) TESTS 23 296 20377600
331236205 aniketcodeforces F July 28, 2025, 3:08 a.m. OK C++20 (GCC 13-64) TESTS 23 296 20480000
331220975 Kalashnikov F July 27, 2025, 10:59 p.m. OK C++20 (GCC 13-64) TESTS 23 296 23654400
331220908 Kalashnikov F July 27, 2025, 10:57 p.m. OK C++20 (GCC 13-64) TESTS 23 296 23654400
331192535 Worteltje F July 27, 2025, 5:23 p.m. OK C++20 (GCC 13-64) TESTS 23 312 21504000
331232878 wenqizhi F July 28, 2025, 2:25 a.m. OK C++20 (GCC 13-64) TESTS 23 343 32665600
331202824 maspy F July 27, 2025, 6:36 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 140 26214400
331241967 tin.le2 F July 28, 2025, 4:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 250 11468800
331242438 YuiYagi F July 28, 2025, 4:36 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 265 12492800
331211168 _Filya_ F July 27, 2025, 8:09 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 280 19865600
331202184 zer0- F July 27, 2025, 6:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 296 19968000
331229882 scanhex F July 28, 2025, 1:46 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 296 30822400
331201788 zer0- F July 27, 2025, 6:27 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 311 19865600
331205794 arvink_cf F July 27, 2025, 7:07 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 312 12492800
331204889 arvindk0025 F July 27, 2025, 6:57 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 312 12492800
331193698 A_G F July 27, 2025, 5:28 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 312 12492800
331241011 warframe F July 28, 2025, 4:14 a.m. OK Java 8 TESTS 23 1936 55296000
331232618 banibrata2007 F July 28, 2025, 2:21 a.m. OK PyPy 3-64 TESTS 23 1093 107724800

remove filters

Back to search problems