Codeforces Round 963 (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
1993 Codeforces Round 963 (Div. 2) FINISHED False 7200 53623523 Aug. 4, 2024, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 541 ) F2 Dyn-scripted Robot (Hard Version) PROGRAMMING chinese remainder theorem math number theory

This is the hard version of the problem. The only difference is that in this version (k \le 10^{12}). You can make hacks only if both versions of the problem are solved. Given a (w \times h) rectangle on the (Oxy) plane, with points ((0, 0)) at the bottom-left and ((w, h)) at the top-right of the rectangle. You also have a robot initially at point ((0, 0)) and a script (s) of (n) characters. Each character is either L , R , U , or D , which tells the robot to move left, right, up, or down respectively. The robot can only move inside the rectangle; otherwise, it will change the script (s) as follows: If it tries to move outside a vertical border, it changes all L characters to R 's (and vice versa, all R 's to L 's). If it tries to move outside a horizontal border, it changes all U characters to D 's (and vice versa, all D 's to U 's). Then, it will execute the changed script starting from the character which it couldn't execute. The script (s) will be executed for (k) times continuously. All changes to the string (s) will be retained even when it is repeated. During this process, how many times will the robot move to the point ((0, 0)) in total? Note that the initial position does NOT count . The first line contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains four integers (n), (k), (w), and (h) ((1 \le n, w, h \le 10^6); (1 \le k \le 10^{12})). The second line contains a single string (s) of size (n) ((s_i \in \{L, R, U, D\})) — the script to be executed. It is guaranteed that the sum of (n) over all test cases does not exceed (10^6). For each test case, print a single integer — the number of times the robot reaches ((0, 0)) when executing script (s) for (k) times continuously. In the first test case, the robot only moves up and right for

Tutorials

Editorial of Codeforces Round 963 (Div. 2)

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
274455982 omeganot F2 Aug. 5, 2024, 12:21 a.m. OK C++14 (GCC 6-32) TESTS 25 234 9932800
274478612 liujg F2 Aug. 5, 2024, 5:23 a.m. OK C++14 (GCC 6-32) TESTS 25 546 16076800
274466357 chenjunxiu F2 Aug. 5, 2024, 2:53 a.m. OK C++14 (GCC 6-32) TESTS 25 562 8089600
274478692 liujg F2 Aug. 5, 2024, 5:23 a.m. OK C++14 (GCC 6-32) TESTS 25 562 16076800
274466589 chenjunxiu F2 Aug. 5, 2024, 2:56 a.m. OK C++14 (GCC 6-32) TESTS 25 609 7987200
274466278 chenjunxiu F2 Aug. 5, 2024, 2:52 a.m. OK C++14 (GCC 6-32) TESTS 25 609 8089600
274465777 chenjunxiu F2 Aug. 5, 2024, 2:47 a.m. OK C++14 (GCC 6-32) TESTS 25 624 7987200
274465985 chenjunxiu F2 Aug. 5, 2024, 2:49 a.m. OK C++14 (GCC 6-32) TESTS 25 624 8089600
274458140 luogu_bot5 F2 Aug. 5, 2024, 1:03 a.m. OK C++14 (GCC 6-32) TESTS 25 1390 16076800
274450510 golions F2 Aug. 4, 2024, 10:03 p.m. OK C++17 (GCC 7-32) TESTS 25 343 0
274458175 pengyantong F2 Aug. 5, 2024, 1:03 a.m. OK C++17 (GCC 7-32) TESTS 25 437 0
274481437 cn449 F2 Aug. 5, 2024, 5:50 a.m. OK C++17 (GCC 7-32) TESTS 25 499 35225600
274425658 skyhgzsh F2 Aug. 4, 2024, 5:37 p.m. OK C++17 (GCC 7-32) TESTS 25 530 102400
274423825 GoogleBot F2 Aug. 4, 2024, 5:30 p.m. OK C++17 (GCC 7-32) TESTS 25 546 10137600
274481332 cn449 F2 Aug. 5, 2024, 5:49 a.m. OK C++17 (GCC 7-32) TESTS 25 546 35123200
274472851 infinity0 F2 Aug. 5, 2024, 4:14 a.m. OK C++17 (GCC 7-32) TESTS 25 577 13312000
274426601 HCPS42 F2 Aug. 4, 2024, 5:42 p.m. OK C++17 (GCC 7-32) TESTS 25 827 8089600
274425974 undisputed42 F2 Aug. 4, 2024, 5:39 p.m. OK C++17 (GCC 7-32) TESTS 25 827 8089600
274461479 whdywjd F2 Aug. 5, 2024, 1:54 a.m. OK C++20 (GCC 13-64) TESTS 25 218 167424000
274449133 perchuts F2 Aug. 4, 2024, 9:34 p.m. OK C++20 (GCC 13-64) TESTS 25 233 0
274418028 DylanSmith F2 Aug. 4, 2024, 4:30 p.m. OK C++20 (GCC 13-64) TESTS 25 265 1228800
274481929 JoesSR F2 Aug. 5, 2024, 5:55 a.m. OK C++20 (GCC 13-64) TESTS 25 281 1024000
274417256 ShiinaTaki F2 Aug. 4, 2024, 4:28 p.m. OK C++20 (GCC 13-64) TESTS 25 281 167424000
274446260 stan23456 F2 Aug. 4, 2024, 8:51 p.m. OK C++20 (GCC 13-64) TESTS 25 296 1331200
274430628 LOOP0 F2 Aug. 4, 2024, 6:08 p.m. OK C++20 (GCC 13-64) TESTS 25 311 2969600
274428045 marvinthang F2 Aug. 4, 2024, 5:51 p.m. OK C++20 (GCC 13-64) TESTS 25 311 6451200
274424522 propane F2 Aug. 4, 2024, 5:32 p.m. OK C++20 (GCC 13-64) TESTS 25 311 7475200
274424412 ttamx F2 Aug. 4, 2024, 5:31 p.m. OK C++20 (GCC 13-64) TESTS 25 312 1228800
274452068 profchi F2 Aug. 4, 2024, 10:40 p.m. OK Java 8 TESTS 25 452 6041600
274451246 profchi F2 Aug. 4, 2024, 10:20 p.m. OK Java 8 TESTS 25 452 6041600
274442556 bronze_coder F2 Aug. 4, 2024, 8:03 p.m. OK PyPy 3-64 TESTS 25 1234 62668800
274479312 tan-jie-xi F2 Aug. 5, 2024, 5:30 a.m. OK PyPy 3-64 TESTS 25 1280 62259200

remove filters

Back to search problems