Codeforces Round 1002 (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
2059 Codeforces Round 1002 (Div. 2) FINISHED False 7200 37898722 Feb. 2, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 6493 ) D Graph and Graph PROGRAMMING data structures graphs greedy shortest paths

You are given two connected undirected graphs with the same number of vertices. In both graphs, there is a token located at some vertex. In the first graph, the token is initially at vertex (s_1), and in the second graph, the token is initially at vertex (s_2). The following operation is repeated an infinite number of times: Let the token currently be at vertex (v_1) in the first graph and at vertex (v_2) in the second graph. A vertex (u_1), adjacent to (v_1), is chosen in the first graph. A vertex (u_2), adjacent to (v_2), is chosen in the second graph. The tokens are moved to the chosen vertices: in the first graph, the token moves from (v_1) to (u_1), and in the second graph, from (v_2) to (u_2). The cost of such an operation is equal to (|u_1 - u_2|). Determine the minimum possible total cost of all operations or report that this value will be infinitely large. Each test consists of multiple test cases. The first line contains one integer (t) ((1 \le t \le 500)) — the number of test cases. The description of the test cases follows. The first line of each test case contains three integers (n), (s_1), and (s_2) ((2 \le n \le 1000), (1 \le s_1, s_2 \le n)) — the number of vertices in each graph, the number of the vertex in the first graph where the token is initially located, and the number of the vertex in the second graph where the token is initially located. The second line of each test case contains one integer (m_1) ((1 \le m_1 \le 1000)) — the number of edges in the first graph. The (i)-th of the following (m_1) lines contains two integers (a_i) and (b_i) ((1 \le a_i, b_i \le n), (a_i \ne b_i)) — the numbers of the endpoints of the (i)-th edge in the first graph. The next line of each test case contains one integer (m_2) ((1 \le m_2 \le 1000)) — the number of edges in the second graph. The (j)-th of the following (m_2)

Tutorials

139094

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
304212985 _Equinox D Feb. 3, 2025, 5:48 a.m. OK C# 10 TESTS 24 546 63692800
304258147 dorjderem D Feb. 3, 2025, 1:40 p.m. OK C# 10 TESTS 24 562 43212800
304219535 F3R618 D Feb. 3, 2025, 8:44 a.m. OK C++17 (GCC 7-32) TESTS 24 233 13004800
304330085 a84256236 D Feb. 3, 2025, 11:32 p.m. OK C++17 (GCC 7-32) TESTS 24 233 19456000
304304778 devanshv17 D Feb. 3, 2025, 6:26 p.m. OK C++17 (GCC 7-32) TESTS 24 249 13004800
304291893 Xh_QwQ D Feb. 3, 2025, 5:06 p.m. OK C++17 (GCC 7-32) TESTS 24 249 13107200
304305318 Hs_Galaxy D Feb. 3, 2025, 6:30 p.m. OK C++17 (GCC 7-32) TESTS 24 249 19456000
304227995 A_M14 D Feb. 3, 2025, 9:54 a.m. OK C++17 (GCC 7-32) TESTS 24 249 19558400
304245697 coder.cpp D Feb. 3, 2025, 12:15 p.m. OK C++17 (GCC 7-32) TESTS 24 249 19660800
304193926 Broder D Feb. 3, 2025, 12:25 a.m. OK C++17 (GCC 7-32) TESTS 24 250 19148800
304313754 _dhruveel_gajipara_ D Feb. 3, 2025, 7:39 p.m. OK C++17 (GCC 7-32) TESTS 24 250 19660800
304205928 yuyc D Feb. 3, 2025, 4:20 a.m. OK C++17 (GCC 7-32) TESTS 24 250 22220800
304265832 parth_sak12 D Feb. 3, 2025, 2:24 p.m. OK C++20 (GCC 13-64) TESTS 24 93 39628800
304268235 Darkmastergat D Feb. 3, 2025, 2:37 p.m. OK C++20 (GCC 13-64) TESTS 24 202 22425600
304236875 RGB_ICPC1 D Feb. 3, 2025, 11:08 a.m. OK C++20 (GCC 13-64) TESTS 24 218 13209600
304341777 TwindT D Feb. 4, 2025, 3:55 a.m. OK C++20 (GCC 13-64) TESTS 24 218 19558400
304196530 xzczxczxc D Feb. 3, 2025, 1:32 a.m. OK C++20 (GCC 13-64) TESTS 24 218 19763200
304204880 zheng_zijian D Feb. 3, 2025, 4:06 a.m. OK C++20 (GCC 13-64) TESTS 24 218 24268800
304202111 ChengyunSun D Feb. 3, 2025, 3:23 a.m. OK C++20 (GCC 13-64) TESTS 24 218 28774400
304180295 tejkumar_40 D Feb. 2, 2025, 8:32 p.m. OK C++20 (GCC 13-64) TESTS 24 234 13312000
304201249 trainerherp D Feb. 3, 2025, 3:09 a.m. OK C++20 (GCC 13-64) TESTS 24 249 20684800
304306081 Xx_star D Feb. 3, 2025, 6:36 p.m. OK C++20 (GCC 13-64) TESTS 24 249 24473600
304265944 parth_sak12 D Feb. 3, 2025, 2:25 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 108 39321600
304208061 You_See_Me D Feb. 3, 2025, 4:49 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 186 19763200
304235238 yojit6073 D Feb. 3, 2025, 10:54 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 186 20275200
304184426 khanxbahria D Feb. 2, 2025, 9:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 186 30617600
304222115 beta99999 D Feb. 3, 2025, 9:07 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 187 7987200
304273710 ashu_2211 D Feb. 3, 2025, 3:09 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 187 19660800
304207704 You_See_Me D Feb. 3, 2025, 4:44 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 202 20172800
304201782 xing_yao D Feb. 3, 2025, 3:18 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 217 98816000
304300227 tonyhawkcxx D Feb. 3, 2025, 5:58 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 218 31744000
304190151 coding_kage_04 D Feb. 2, 2025, 10:56 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 233 14028800
304194288 xylu D Feb. 3, 2025, 12:35 a.m. OK Go TESTS 24 483 123904000
304194225 xylu D Feb. 3, 2025, 12:33 a.m. OK Go TESTS 24 687 123904000
304196426 uffhottie D Feb. 3, 2025, 1:30 a.m. OK Go TESTS 24 1218 119500800
304197122 uffhottie D Feb. 3, 2025, 1:46 a.m. OK Go TESTS 24 1484 194764800
304249265 sreecharanreddypacharla D Feb. 3, 2025, 12:42 p.m. OK Java 21 TESTS 24 1374 57651200
304191525 mangos194 D Feb. 2, 2025, 11:25 p.m. OK Java 21 TESTS 24 1390 72192000
304200654 InfinityX D Feb. 3, 2025, 2:58 a.m. OK Java 21 TESTS 24 1421 56320000
304180346 Anas45 D Feb. 2, 2025, 8:32 p.m. OK Java 21 TESTS 24 1421 73318400
304180786 polsage D Feb. 2, 2025, 8:37 p.m. OK Java 21 TESTS 24 1530 64409600
304193778 testtest111ksjfrdvn D Feb. 3, 2025, 12:22 a.m. OK Java 21 TESTS 24 1983 90931200
304323343 MarcAS D Feb. 3, 2025, 9:23 p.m. OK Java 8 TESTS 24 1218 30515200
304305205 chiragsingh876 D Feb. 3, 2025, 6:29 p.m. OK Java 8 TESTS 24 1874 51814400
304183898 conqueror_of_tourist D Feb. 2, 2025, 9:16 p.m. OK PyPy 3 TESTS 24 1406 19865600
304315896 Sedulous123 D Feb. 3, 2025, 8 p.m. OK PyPy 3 TESTS 24 1578 47718400
304184049 conqueror_of_tourist D Feb. 2, 2025, 9:18 p.m. OK PyPy 3 TESTS 24 1624 20787200
304232820 jahnvisahni98 D Feb. 3, 2025, 10:34 a.m. OK PyPy 3-64 TESTS 24 671 36556800
304190355 Polynomu D Feb. 2, 2025, 11 p.m. OK PyPy 3-64 TESTS 24 671 39014400
304192452 explainer D Feb. 2, 2025, 11:48 p.m. OK PyPy 3-64 TESTS 24 702 36556800
304270210 explainer D Feb. 3, 2025, 2:48 p.m. OK PyPy 3-64 TESTS 24 749 37478400
304192363 explainer D Feb. 2, 2025, 11:46 p.m. OK PyPy 3-64 TESTS 24 765 37478400
304330803 akioweh D Feb. 3, 2025, 11:53 p.m. OK PyPy 3-64 TESTS 24 780 40243200
304308849 gardengnome D Feb. 3, 2025, 6:57 p.m. OK PyPy 3-64 TESTS 24 781 39219200
304180898 gardengnome D Feb. 2, 2025, 8:39 p.m. OK PyPy 3-64 TESTS 24 781 50585600
304349226 minuki646 D Feb. 4, 2025, 5:41 a.m. OK PyPy 3-64 TESTS 24 984 62054400
304350247 minuki646 D Feb. 4, 2025, 5:52 a.m. OK PyPy 3-64 TESTS 24 1374 60928000
304235045 viniciusth D Feb. 3, 2025, 10:53 a.m. OK Rust 2021 TESTS 24 436 39014400
304337512 cafe6a6e D Feb. 4, 2025, 2:35 a.m. OK Rust 2021 TESTS 24 499 43622400
304235436 viniciusth D Feb. 3, 2025, 10:56 a.m. OK Rust 2021 TESTS 24 530 52531200
304251218 quasar142857 D Feb. 3, 2025, 12:57 p.m. OK Rust 2021 TESTS 24 1124 101580800

remove filters

Back to search problems