Codeforces Round 1114 (Div. 3)

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
2254 Codeforces Round 1114 (Div. 3) FINISHED False 8100 2301884 Aug. 4, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 13117 ) C2 Marenol (hard version) PROGRAMMING greedy sortings

This is the hard version of the problem. In this version, you are asked to determine the minimum number of operations to transform (a) into (b). Yousef has given you two binary strings, (a) and (b), of the same length (n). You are allowed to perform any of the following operations: Choose a substring(^{\text{∗}}) in (a) equal to (001) and replace it with (100), or vice versa (i.e. (001 \rightarrow 100) or (100 \rightarrow \texttt {001})). Choose a substring in (a) equal to (110) and replace it with (011), or vice versa (i.e. (011 \rightarrow 110) or (110 \rightarrow \texttt {011})). Your task is to determine the minimum number of operations required to transform string (a) into string (b). If it is impossible to transform (a) into (b) using the given operations, output (-1) instead. (^{\text{∗}})A string (a) is a substring of a string (b) if (a) can be obtained from (b) by deletion of several (possibly zero or all) characters from the beginning and several (possibly zero or all) characters from the end. 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 a single integer (n) ((1 \le n \le 2 \cdot 10^5)) — the length of each string. The second line of each test case contains a binary string (a) ((|a| = n)), consisting of only characters (0) and/or (1). The third line of each test case contains a binary string (b) ((|b| = n)), consisting of only characters (0) and/or (1). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output the minimum number of operations required to transform (a) into (b). If it is impossible, output $$$-1$

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
385672234 TomoyoSakagami C2 Aug. 4, 2026, 4:46 p.m. OK C# 13 TESTS 11 78 4403200
385672378 PlievD C2 Aug. 4, 2026, 4:46 p.m. OK C# 13 TESTS 11 109 5939200
385833466 adarsh_singh23 C2 Aug. 6, 2026, 4:43 a.m. OK C++17 (GCC 7-32) TESTS 11 31 0
385816761 Ayyapparaju C2 Aug. 6, 2026, 12:48 a.m. OK C++17 (GCC 7-32) TESTS 11 31 0
385793882 j.archit C2 Aug. 5, 2026, 6:03 p.m. OK C++17 (GCC 7-32) TESTS 11 31 0
385717764 Turtle183 C2 Aug. 5, 2026, 5:18 a.m. OK C++17 (GCC 7-32) TESTS 11 31 0
385716053 tralaleoLahoax C2 Aug. 5, 2026, 4:54 a.m. OK C++17 (GCC 7-32) TESTS 11 31 0
385713019 Ruhangrk C2 Aug. 5, 2026, 4:07 a.m. OK C++17 (GCC 7-32) TESTS 11 31 0
385712044 bhuvantiwari902 C2 Aug. 5, 2026, 3:52 a.m. OK C++17 (GCC 7-32) TESTS 11 31 0
385710832 A.A.Maruf C2 Aug. 5, 2026, 3:34 a.m. OK C++17 (GCC 7-32) TESTS 11 31 0
385671845 sumblazeofdu C2 Aug. 4, 2026, 4:46 p.m. OK C++17 (GCC 7-32) TESTS 11 31 0
385670253 gobig_O C2 Aug. 4, 2026, 4:43 p.m. OK C++17 (GCC 7-32) TESTS 11 31 0
385717133 qinix C2 Aug. 5, 2026, 5:09 a.m. OK C++20 (GCC 13-64) TESTS 11 15 0
385836639 sunil8777 C2 Aug. 6, 2026, 5:32 a.m. OK C++20 (GCC 13-64) TESTS 11 31 0
385838999 khelahobe_01 C2 Aug. 6, 2026, 6:05 a.m. OK C++20 (GCC 13-64) TESTS 11 31 102400
385830123 GOD_VIPUL C2 Aug. 6, 2026, 3:46 a.m. OK C++20 (GCC 13-64) TESTS 11 31 102400
385808796 olasiliksizci C2 Aug. 5, 2026, 8:49 p.m. OK C++20 (GCC 13-64) TESTS 11 31 102400
385803791 code_breaker073 C2 Aug. 5, 2026, 7:30 p.m. OK C++20 (GCC 13-64) TESTS 11 31 102400
385802462 Phantom_26 C2 Aug. 5, 2026, 7:14 p.m. OK C++20 (GCC 13-64) TESTS 11 31 102400
385800847 CrazyAdventurer C2 Aug. 5, 2026, 6:56 p.m. OK C++20 (GCC 13-64) TESTS 11 31 102400
385719185 SisyphusPath C2 Aug. 5, 2026, 5:35 a.m. OK C++20 (GCC 13-64) TESTS 11 31 102400
385707472 Mai_Dang373 C2 Aug. 5, 2026, 2:40 a.m. OK C++20 (GCC 13-64) TESTS 11 31 102400
385719479 sodayo C2 Aug. 5, 2026, 5:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 15 102400
385809963 Yanghuaaa C2 Aug. 5, 2026, 9:14 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 31 0
385809904 vishal340 C2 Aug. 5, 2026, 9:13 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 31 0
385809870 RReyes2612 C2 Aug. 5, 2026, 9:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 31 0
385807894 mayankt45 C2 Aug. 5, 2026, 8:32 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 31 0
385806308 TouhidAhmed C2 Aug. 5, 2026, 8:06 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 31 0
385805519 mehdiCS C2 Aug. 5, 2026, 7:54 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 31 0
385802046 AndersDB5 C2 Aug. 5, 2026, 7:09 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 31 0
385799327 _gautam_11 C2 Aug. 5, 2026, 6:41 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 31 0
385799022 El-Abiad C2 Aug. 5, 2026, 6:38 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 31 0
385670102 CodeSagar C2 Aug. 4, 2026, 4:42 p.m. OK GNU C11 TESTS 11 62 6860800
385673894 Destroyer30 C2 Aug. 4, 2026, 4:49 p.m. OK GNU C11 TESTS 11 78 3686400
385716868 YongZhang C2 Aug. 5, 2026, 5:05 a.m. OK GNU C11 TESTS 11 93 3788800
385824599 daidao C2 Aug. 6, 2026, 2:40 a.m. OK Go TESTS 11 46 5836800
385670479 Yahalosse C2 Aug. 4, 2026, 4:43 p.m. OK Go TESTS 11 218 7475200
385798487 abhi-raj C2 Aug. 5, 2026, 6:33 p.m. OK Java 21 TESTS 11 203 1331200
385714429 Material_humbled_fool C2 Aug. 5, 2026, 4:29 a.m. OK Java 21 TESTS 11 203 3891200
385720294 alelapolema_1027 C2 Aug. 5, 2026, 5:49 a.m. OK Java 21 TESTS 11 218 204800
385812850 Outlastqr C2 Aug. 5, 2026, 10:35 p.m. OK Java 21 TESTS 11 218 614400
385830581 sriram_18 C2 Aug. 6, 2026, 3:53 a.m. OK Java 21 TESTS 11 218 716800
385710568 orzMe C2 Aug. 5, 2026, 3:30 a.m. OK Java 21 TESTS 11 218 716800
385833667 krishanbhadala99 C2 Aug. 6, 2026, 4:46 a.m. OK Java 21 TESTS 11 218 3174400
385672836 nkit_dev01 C2 Aug. 4, 2026, 4:47 p.m. OK Java 21 TESTS 11 218 3993600
385801413 bethebest100times C2 Aug. 5, 2026, 7:02 p.m. OK Java 21 TESTS 11 218 5939200
385833794 Mega6776 C2 Aug. 6, 2026, 4:48 a.m. OK Java 21 TESTS 11 234 3686400
385674489 prabhatchauhan04 C2 Aug. 4, 2026, 4:49 p.m. OK Java 8 TESTS 11 156 0
385673408 TheJavaGuy C2 Aug. 4, 2026, 4:48 p.m. OK Java 8 TESTS 11 156 1228800
385801714 Yaser2004 C2 Aug. 5, 2026, 7:05 p.m. OK Java 8 TESTS 11 203 3276800
385799626 harshmt.23 C2 Aug. 5, 2026, 6:43 p.m. OK Java 8 TESTS 11 218 0
385673604 shreyamane C2 Aug. 4, 2026, 4:48 p.m. OK Java 8 TESTS 11 218 3276800
385672436 anirudhabcd C2 Aug. 4, 2026, 4:47 p.m. OK Java 8 TESTS 11 250 0
385674399 Visheshp_05 C2 Aug. 4, 2026, 4:49 p.m. OK Java 8 TESTS 11 265 0
385821276 Shafat04 C2 Aug. 6, 2026, 2:03 a.m. OK Java 8 TESTS 11 1468 8806400
385810565 Georgy_Hryashev C2 Aug. 5, 2026, 9:28 p.m. OK PyPy 3 TESTS 11 359 13619200
385672626 AlgoLord C2 Aug. 4, 2026, 4:47 p.m. OK PyPy 3 TESTS 11 406 9523200
385670774 MulukenS C2 Aug. 4, 2026, 4:44 p.m. OK PyPy 3-64 TESTS 11 140 9728000
385723653 Bakytz7zaN C2 Aug. 5, 2026, 6:34 a.m. OK PyPy 3-64 TESTS 11 187 8806400
385672875 abelkj C2 Aug. 4, 2026, 4:47 p.m. OK PyPy 3-64 TESTS 11 187 9216000
385776182 aYu4ko C2 Aug. 5, 2026, 3:32 p.m. OK PyPy 3-64 TESTS 11 187 9420800
385669936 Asterix22 C2 Aug. 4, 2026, 4:42 p.m. OK PyPy 3-64 TESTS 11 187 9420800
385673183 e4b063ad69e0 C2 Aug. 4, 2026, 4:48 p.m. OK PyPy 3-64 TESTS 11 187 9523200
385670331 Low_levell C2 Aug. 4, 2026, 4:43 p.m. OK PyPy 3-64 TESTS 11 203 8601600
385798916 santo_boi C2 Aug. 5, 2026, 6:37 p.m. OK PyPy 3-64 TESTS 11 203 9216000
385671632 qwe435231 C2 Aug. 4, 2026, 4:45 p.m. OK PyPy 3-64 TESTS 11 203 10035200
385712466 r0amer C2 Aug. 5, 2026, 3:58 a.m. OK PyPy 3-64 TESTS 11 203 10956800
385672380 dark_king324 C2 Aug. 4, 2026, 4:46 p.m. OK Python 3 TESTS 11 109 10956800
385672339 pragyan_np C2 Aug. 4, 2026, 4:46 p.m. OK Python 3 TESTS 11 109 13516800
385674511 bombaycoder C2 Aug. 4, 2026, 4:49 p.m. OK Python 3 TESTS 11 125 13926400
385670970 hhqqyyang C2 Aug. 4, 2026, 4:44 p.m. OK Python 3 TESTS 11 125 14233600
385715811 gooonn C2 Aug. 5, 2026, 4:50 a.m. OK Python 3 TESTS 11 125 16588800
385723774 z0ne C2 Aug. 5, 2026, 6:35 a.m. OK Python 3 TESTS 11 140 6860800
385718358 adityaa6 C2 Aug. 5, 2026, 5:24 a.m. OK Python 3 TESTS 11 140 9932800
385807758 Anurag_singh_2712 C2 Aug. 5, 2026, 8:30 p.m. OK Python 3 TESTS 11 156 7372800
385671569 coder701 C2 Aug. 4, 2026, 4:45 p.m. OK Python 3 TESTS 11 156 7372800
385796505 Lebn1tz C2 Aug. 5, 2026, 6:20 p.m. OK Python 3 TESTS 11 156 11468800
385817231 kroyl C2 Aug. 6, 2026, 12:59 a.m. OK Rust 2024 TESTS 11 31 0
385808542 ceadrianguevara2004 C2 Aug. 5, 2026, 8:44 p.m. OK Rust 2024 TESTS 11 31 819200
385805252 mxrse C2 Aug. 5, 2026, 7:50 p.m. OK Rust 2024 TESTS 11 46 0
385794781 ivantdev C2 Aug. 5, 2026, 6:09 p.m. OK Rust 2024 TESTS 11 46 0
385712712 Tantellam C2 Aug. 5, 2026, 4:02 a.m. OK Rust 2024 TESTS 11 46 204800
385805313 mxrse C2 Aug. 5, 2026, 7:51 p.m. OK Rust 2024 TESTS 11 62 0
385795626 honeycrux C2 Aug. 5, 2026, 6:14 p.m. OK Rust 2024 TESTS 11 78 2662400

remove filters

Back to search problems