Codeforces Round 1030 (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
2118 Codeforces Round 1030 (Div. 2) FINISHED False 7200 26666723 June 12, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 2481 ) D2 Red Light, Green Light (Hard version) PROGRAMMING binary search dfs and similar dp dsu graphs implementation number theory

This is the hard version of the problem. The only difference is the constraint on (k) and the total sum of (n) and (q) across all test cases. You can make hacks only if both versions of the problem are solved. You are given a strip of length (10^{15}) and a constant (k). There are exactly (n) cells that contain a traffic light; each has a position (p_i) and an initial delay (d_i) for which (d_i < k). The (i)-th traffic light works the following way: it shows red at the (l \cdot k + d_i)-th second, where (l) is an integer, it shows green otherwise. At second (0), you are initially positioned at some cell on the strip, facing the positive direction. At each second, you perform the following actions in order: If the current cell contains a red traffic light, you turn around. Move one cell in the direction you are currently facing. You are given (q) different starting positions. For each one, determine whether you will eventually leave the strip within (10^{100}) seconds. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 2\cdot10^5)). The description of the test cases follows. The first line of each test case contains two integers (n), (k) ((\mathbf{1 \le n \le 2\cdot10^5}) and (\mathbf{1 \le k \le 10^{15}})) — the number of traffic lights and the length of the period. The second line of each test case contains (n) integers (p_1, p_2, \ldots p_n) ((1 \le p_1 < p_2 < \ldots < p_n \le 10^{15})) — the positions of the traffic lights. The third line of each test case contains (n) integers (d_1, d_2, \ldots d_n) ((0 \le d_i < k)) — the delays of the traffic lights. The fourth line of each test case contains one integer (q) ((\mathbf{1 \le q \le 2\cdot10^5})) — the number of queries. The fifth line of each test case contains (q) integers (a_1, a_2, \ldots, a_q) ($$$1 \leq a_i \leq 10^{15}

Tutorials

Codeforces Round 1030 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
324144123 og.kostya D2 June 12, 2025, 5:32 p.m. OK C# 10 TESTS 36 311 26112000
324144417 og.kostya D2 June 12, 2025, 5:34 p.m. OK C# 13 TESTS 36 546 18739200
324140249 -firefly- D2 June 12, 2025, 5:10 p.m. OK C# 13 TESTS 36 1155 57139200
324174584 Yuichiro17 D2 June 13, 2025, 12:27 a.m. OK C++17 (GCC 7-32) TESTS 37 374 23142400
324173831 konghaojie D2 June 13, 2025, 12:07 a.m. OK C++17 (GCC 7-32) TESTS 37 374 23654400
324162121 repmann D2 June 12, 2025, 8:05 p.m. OK C++17 (GCC 7-32) TESTS 37 374 24064000
324146488 god-knows-who D2 June 12, 2025, 5:47 p.m. OK C++17 (GCC 7-32) TESTS 37 390 23142400
324197587 renegade1050 D2 June 13, 2025, 5:47 a.m. OK C++17 (GCC 7-32) TESTS 37 405 45158400
324175094 ForwardStar D2 June 13, 2025, 12:39 a.m. OK C++17 (GCC 7-32) TESTS 37 421 47616000
324171865 Cody473 D2 June 12, 2025, 11:10 p.m. OK C++17 (GCC 7-32) TESTS 37 436 26931200
324142212 smatskevich D2 June 12, 2025, 5:20 p.m. OK C++17 (GCC 7-32) TESTS 36 437 29696000
324136399 HeartBlueArchive D2 June 12, 2025, 4:34 p.m. OK C++17 (GCC 7-32) TESTS 36 437 35942400
324169146 robert.barbu27 D2 June 12, 2025, 9:57 p.m. OK C++17 (GCC 7-32) TESTS 37 452 30105600
324160062 kaiboy D2 June 12, 2025, 7:40 p.m. OK C++20 (GCC 13-64) TESTS 37 296 17715200
324148476 iordache_ D2 June 12, 2025, 6:01 p.m. OK C++20 (GCC 13-64) TESTS 37 327 36966400
324182850 cwz2024 D2 June 13, 2025, 2:55 a.m. OK C++20 (GCC 13-64) TESTS 37 343 35737600
324194638 piaoyun D2 June 13, 2025, 5:18 a.m. OK C++20 (GCC 13-64) TESTS 37 343 83660800
324175334 876pol D2 June 13, 2025, 12:44 a.m. OK C++20 (GCC 13-64) TESTS 37 359 24678400
324135344 rshohruh D2 June 12, 2025, 4:33 p.m. OK C++20 (GCC 13-64) TESTS 36 359 25190400
324191487 ChenHuaXin D2 June 13, 2025, 4:47 a.m. OK C++20 (GCC 13-64) TESTS 37 390 31744000
324182239 CrazyApple D2 June 13, 2025, 2:46 a.m. OK C++20 (GCC 13-64) TESTS 37 390 53248000
324181765 GGodSSpeed D2 June 13, 2025, 2:39 a.m. OK C++20 (GCC 13-64) TESTS 37 390 53248000
324156338 andycoke D2 June 12, 2025, 6:58 p.m. OK C++20 (GCC 13-64) TESTS 37 405 33075200
324146257 Rychao D2 June 12, 2025, 5:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 37 327 45875200
324132535 Guitar_Jasmine D2 June 12, 2025, 4:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 36 358 41676800
324140280 TheYashB D2 June 12, 2025, 5:11 p.m. OK C++23 (GCC 14-64, msys2) TESTS 36 358 42188800
324145582 SpyrosAliv D2 June 12, 2025, 5:41 p.m. OK C++23 (GCC 14-64, msys2) TESTS 37 374 54169600
324195694 Dongchy666 D2 June 13, 2025, 5:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 37 375 36659200
324180376 A_G D2 June 13, 2025, 2:18 a.m. OK C++23 (GCC 14-64, msys2) TESTS 37 389 29798400
324131391 duckindog D2 June 12, 2025, 4:27 p.m. OK C++23 (GCC 14-64, msys2) TESTS 36 390 43315200
324139244 AgOH D2 June 12, 2025, 5:07 p.m. OK C++23 (GCC 14-64, msys2) TESTS 36 390 43622400
324165968 Thin_time D2 June 12, 2025, 8:57 p.m. OK C++23 (GCC 14-64, msys2) TESTS 37 390 44236800
324193224 abhaasaggarwal D2 June 13, 2025, 5:04 a.m. OK C++23 (GCC 14-64, msys2) TESTS 37 390 46592000
324170177 Bogys D2 June 12, 2025, 10:21 p.m. OK Java 21 TESTS 37 1562 168448000
324142627 1091857051 D2 June 12, 2025, 5:23 p.m. OK Java 21 TESTS 36 2608 256819200
324131176 Sergey.Bankevich D2 June 12, 2025, 4:26 p.m. OK Kotlin 1.7 TESTS 36 2531 290508800
324173683 pplodev D2 June 13, 2025, 12:03 a.m. OK PyPy 2 TESTS 37 2859 103014400
324164139 kobejean D2 June 12, 2025, 8:30 p.m. OK PyPy 3-64 TESTS 37 828 75059200
324152095 kobejean D2 June 12, 2025, 6:28 p.m. OK PyPy 3-64 TESTS 37 828 75059200
324147907 kobejean D2 June 12, 2025, 5:57 p.m. OK PyPy 3-64 TESTS 37 843 66355200
324151668 kobejean D2 June 12, 2025, 6:25 p.m. OK PyPy 3-64 TESTS 37 843 66457600
324148089 kobejean D2 June 12, 2025, 5:58 p.m. OK PyPy 3-64 TESTS 37 843 66867200
324188957 hxu10 D2 June 13, 2025, 4:16 a.m. OK PyPy 3-64 TESTS 37 921 111104000
324147343 kobejean D2 June 12, 2025, 5:52 p.m. OK PyPy 3-64 TESTS 37 968 67993600
324166317 KAMITO D2 June 12, 2025, 9:02 p.m. OK PyPy 3-64 TESTS 37 1108 123084800
324132464 yupooh D2 June 12, 2025, 4:29 p.m. OK PyPy 3-64 TESTS 36 1280 107315200
324156983 sushmanth.dampur8780 D2 June 12, 2025, 7:05 p.m. OK PyPy 3-64 TESTS 37 1483 127590400
324146542 Jimanbanashi D2 June 12, 2025, 5:47 p.m. OK Python 2 TESTS 37 3015 98099200
324133820 galiver2009 D2 June 12, 2025, 4:31 p.m. OK Python 3 TESTS 36 2905 285798400

remove filters

Back to search problems