Codeforces Round 1008 (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
2077 Codeforces Round 1008 (Div. 1) FINISHED False 9000 34787723 March 10, 2025, 2:45 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 133 ) G RGB Walking PROGRAMMING bitmasks chinese remainder theorem dfs and similar graphs number theory

You are given a connected graph with (n) vertices and (m) bidirectional edges with weight not exceeding (x). The (i)-th edge connects vertices (u_i) and (v_i), has weight (w_i), and is assigned a color (c_i) ((1 \leq i \leq m), (1 \leq u_i, v_i \leq n)). The color (c_i) is either red, green, or blue. It is guaranteed that there is at least one edge of each color. For a walk where vertices and edges may be repeated, let (s_r, s_g, s_b) denote the sum of the weights of the red, green, and blue edges that the walk passes through, respectively. If an edge is traversed multiple times, each traversal is counted separately. Find the minimum value of (\max(s_r, s_g, s_b) - \min(s_r, s_g, s_b)) over all possible walks from vertex (1) to vertex (n). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains three integers (n), (m), and (x) ((4 \leq n \leq 2 \cdot 10^5), (n-1 \leq m \leq 2 \cdot 10^5), (1 \leq x \leq 2 \cdot 10^5)) — the number of vertices, the number of edges in the graph, and the upper bound on the weight of the edges, respectively. The next (m) lines each contain three integers (u_i, v_i, w_i) and a letter (c_i) ((1 \leq u_i, v_i \leq n), (1 \leq w_i \leq x)), representing a bidirectional edge between vertices (u_i) and (v_i) with weight (w_i) and color (c_i). The color (c_i) is either 'r', 'g', or 'b', denoting red, green, and blue, respectively. It is guaranteed that the graph is connected and contains at least one edge of each color. The graph may also contain multiple edges and self-loops . Additionally, it is guaranteed that the total sum of all values of (n), the total sum of all values of (m), and the total sum of all values of (x) across all test cases do not

Tutorials

Codeforces Round 1008 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
309919598 cdxcdxcdxcdx G March 11, 2025, 5:52 a.m. OK C++17 (GCC 7-32) TESTS 24 187 30822400
309900914 Big_OmegaToGm G March 11, 2025, 1:31 a.m. OK C++20 (GCC 13-64) TESTS 24 186 9728000
309860088 Ormlis G March 10, 2025, 5:14 p.m. OK C++20 (GCC 13-64) TESTS 24 265 9728000
309848221 ksun48 G March 10, 2025, 4:44 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 187 16486400
309900807 Sparkle_Twilight G March 11, 2025, 1:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 218 19763200
309876038 ttamx G March 10, 2025, 7:38 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 218 19763200
309832760 jiangly G March 10, 2025, 4:06 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 234 11776000
309915851 maroonrk G March 11, 2025, 5:12 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 296 59904000
309851540 Um_nik G March 10, 2025, 4:53 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 421 24576000
309825744 rainboy G March 10, 2025, 3:53 p.m. OK GNU C11 TESTS 24 140 11366400

remove filters

Back to search problems