Codeforces Round 1031 (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
2113 Codeforces Round 1031 (Div. 2) FINISHED False 7200 26427323 June 15, 2025, 9:05 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 402 ) E From Kazan with Love PROGRAMMING brute force graphs trees

Marat is a native of Kazan. Kazan can be represented as an undirected tree consisting of (n) vertices. In his youth, Marat often got into street fights, and now he has (m) enemies, numbered from (1) to (m), living in Kazan along with him. Every day, all the people living in the city go to work. Marat knows that the (i)-th of his enemies lives at vertex (a_i) and works at vertex (b_i). He himself lives at vertex (x) and works at vertex (y). It is guaranteed that (a_i \ne x). All enemies go to work via the shortest path and leave their homes at time (1). That is, if we represent the shortest path between vertices (a_i) and (b_i) as (c_1, c_2, c_3, \ldots, c_k) (where (c_1 = a_i) and (c_k = b_i)), then at the moment (p) ((1 \le p \le k)), the enemy numbered (i) will be at vertex (c_p). Marat really does not want to meet any of his enemies at the same vertex at the same time, as this would create an awkward situation, but they can meet on an edge . Marat also leaves his home at time (1), and at each subsequent moment in time, he can either move to an adjacent vertex or stay at his current one. Note that Marat can only meet the (i)-th enemy at the moments (2, 3, \ldots, k) (where (c_1, c_2, \ldots, c_k) is the shortest path between vertices (a_i) and (b_i)). In other words, starting from the moment after the enemy reaches work, Marat can no longer meet him . Help Marat find the earliest moment in time when he can reach work without encountering any enemies along the way, or determine that it is impossible. 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 four integers (n), (m), (x), and (y) ((2 \le n \le 10^5), (1 \le m \le 200), (1 \le x, y \le n), (x \neq y)) — the numb

Tutorials

Codeforces Round #1031 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
324570178 VitalyKo E June 15, 2025, 8:23 p.m. OK C++17 (GCC 7-32) TESTS 47 515 164044800
324583087 huangyuhan123456 E June 16, 2025, 2:26 a.m. OK C++17 (GCC 7-32) TESTS 47 671 354304000
324582698 huangyuhan123456 E June 16, 2025, 2:18 a.m. OK C++17 (GCC 7-32) TESTS 47 733 355942400
324586240 Skylerrrrr E June 16, 2025, 3:14 a.m. OK C++17 (GCC 7-32) TESTS 47 812 113561600
324586542 __ikun__horro__ E June 16, 2025, 3:17 a.m. OK C++17 (GCC 7-32) TESTS 47 1343 112025600
324585115 Junz_LJL E June 16, 2025, 3 a.m. OK C++17 (GCC 7-32) TESTS 47 1343 112025600
324537962 -adhd- E June 15, 2025, 2:41 p.m. OK C++17 (GCC 7-32) TESTS 47 1406 333209600
324567677 p3n_ph1 E June 15, 2025, 7:39 p.m. OK C++17 (GCC 7-32) TESTS 47 2312 114483200
324507766 getawronganswer E June 15, 2025, 10:52 a.m. OK C++17 (GCC 7-32) TESTS 47 2608 480768000
324524347 VuxNguyen E June 15, 2025, 12:29 p.m. OK C++17 (GCC 7-32) TESTS 47 3234 122368000
324506600 IkunTeddy E June 15, 2025, 10:49 a.m. OK C++20 (GCC 13-64) TESTS 47 733 141414400
324588543 fishcathu E June 16, 2025, 3:41 a.m. OK C++20 (GCC 13-64) TESTS 47 764 126976000
324580017 www_bilibili_com E June 16, 2025, 1:21 a.m. OK C++20 (GCC 13-64) TESTS 47 780 124006400
324559732 tarikul1234 E June 15, 2025, 5:59 p.m. OK C++20 (GCC 13-64) TESTS 47 859 129024000
324522445 makrav E June 15, 2025, 12:10 p.m. OK C++20 (GCC 13-64) TESTS 47 889 237158400
324509438 toniskrijelj E June 15, 2025, 10:57 a.m. OK C++20 (GCC 13-64) TESTS 47 905 158617600
324588743 fishcathu E June 16, 2025, 3:43 a.m. OK C++20 (GCC 13-64) TESTS 47 921 126976000
324558691 fishcathu E June 15, 2025, 5:48 p.m. OK C++20 (GCC 13-64) TESTS 47 1108 202752000
324558231 fishcathu E June 15, 2025, 5:43 p.m. OK C++20 (GCC 13-64) TESTS 47 1124 203468800
324580332 1234567st E June 16, 2025, 1:29 a.m. OK C++20 (GCC 13-64) TESTS 47 1499 148070400
324528204 maspy E June 15, 2025, 1:09 p.m. OK C++23 (GCC 14-64, msys2) TESTS 47 406 121344000
324549721 Wael_Zaiback E June 15, 2025, 4:20 p.m. OK C++23 (GCC 14-64, msys2) TESTS 47 421 98918400
324533401 maspy E June 15, 2025, 1:58 p.m. OK C++23 (GCC 14-64, msys2) TESTS 47 437 121446400
324566747 jiangly E June 15, 2025, 7:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 47 546 405913600
324572911 4mda4mda E June 15, 2025, 9:24 p.m. OK C++23 (GCC 14-64, msys2) TESTS 47 796 149299200
324521458 Blinov_Artemii E June 15, 2025, 12:03 p.m. OK C++23 (GCC 14-64, msys2) TESTS 47 796 225792000
324516642 SomethingNew E June 15, 2025, 11:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 47 921 231321600
324532981 MateiKing80 E June 15, 2025, 1:54 p.m. OK C++23 (GCC 14-64, msys2) TESTS 47 968 242688000
324583504 yyyz04 E June 16, 2025, 2:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 47 1046 432537600
324569982 lbm47 E June 15, 2025, 8:19 p.m. OK C++23 (GCC 14-64, msys2) TESTS 47 1077 218624000
324583284 golomb E June 16, 2025, 2:29 a.m. OK PyPy 3-64 TESTS 47 3140 265011200
324515102 Egor E June 15, 2025, 11:23 a.m. OK Rust 2021 TESTS 47 3812 517017600

remove filters

Back to search problems