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.
Problems
B'Mark has just purchased a rack of n lightbulbs. The state of the lightbulbs can be described with binary string s = s_1s_2 ... s_n , where s_i= texttt{1} means that the i -th lightbulb is turned on, while s_i= texttt{0} means that the i -th lightbulb is turned off. Unfortunately, the lightbulbs are broken, and the only operation he can perform to change the state of the lightbulbs is the following: Mark wants the state of the lightbulbs to be another binary string t . Help Mark determine the minimum number of operations to do so. The first line of the input contains a single integer q ( 1 <= q q <= q 10^4 ) -- the number of test cases. The first line of each test case contains a single integer n ( 3 <= q n <= q 2 cdot 10^5 ) -- the number of lightbulbs. The second line of each test case contains a binary string s of length n -- the initial state of the lightbulbs. The third line of each test case contains a binary string t of length n -- the final state of the lightbulbs. It is guaranteed that the sum of n across all test cases does not exceed 2 cdot 10^5 . For each test case, print a line containing the minimum number of operations Mark needs to perform to transform s to t . If there is no such sequence of operations, print -1 . In the first test case, one sequence of operations that achieves the minimum number of operations is the following. In the third test case, even though the first digits of s and t are the same and the last digits of s and t are the same, it can be shown that there is no sequence of operations that satisfies the condition. In the fourth test case, one sequence that achieves the minimum number of operations is the following: '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
164392573 |
Tdyx |
D |
July 16, 2022, 4:12 a.m. |
OK |
C# 8 |
TESTS |
18 |
155 |
3276800 |
|
|
164379146 |
Pcjmy |
D |
July 16, 2022, 1:07 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
18 |
264 |
17510400 |
|
|
164401402 |
1533050560 |
D |
July 16, 2022, 5:57 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
18 |
295 |
21401600 |
|
|
164362920 |
gotcoding124 |
D |
July 15, 2022, 7:33 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
18 |
420 |
47718400 |
|
|
164391926 |
bkifhr8 |
D |
July 16, 2022, 4:03 a.m. |
OK |
GNU C11 |
TESTS |
18 |
62 |
2048000 |
|
|
164357342 |
caan_do |
D |
July 15, 2022, 6:27 p.m. |
OK |
GNU C++14 |
TESTS |
18 |
15 |
409600 |
|
|
164343481 |
songhaoran |
D |
July 15, 2022, 4:28 p.m. |
OK |
GNU C++14 |
TESTS |
18 |
15 |
409600 |
|
|
164370009 |
ahmed-abd-elrazik |
D |
July 15, 2022, 9:26 p.m. |
OK |
GNU C++14 |
TESTS |
18 |
15 |
409600 |
|
|
164385388 |
YdGod |
D |
July 16, 2022, 2:45 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
15 |
2048000 |
|
|
164380345 |
rechinist |
D |
July 16, 2022, 1:29 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
15 |
2048000 |
|
|
164393938 |
cxcxccx |
D |
July 16, 2022, 4:31 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
15 |
2048000 |
|
|
164345058 |
lpxlove |
D |
July 15, 2022, 4:37 p.m. |
OK |
GNU C++14 |
TESTS |
18 |
15 |
3174400 |
|
|
164392360 |
Hytidel |
D |
July 16, 2022, 4:09 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
15 |
3481600 |
|
|
164374914 |
dengziyue |
D |
July 15, 2022, 11:14 p.m. |
OK |
GNU C++14 |
TESTS |
18 |
15 |
3584000 |
|
|
164380888 |
hgzxwzf |
D |
July 16, 2022, 1:38 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
15 |
3584000 |
|
|
164338913 |
fwtt2 |
D |
July 15, 2022, 3:48 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
15 |
409600 |
|
|
164338493 |
dtsarun |
D |
July 15, 2022, 3:48 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
15 |
716800 |
|
|
164342495 |
Gabp |
D |
July 15, 2022, 4:24 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
15 |
1536000 |
|
|
164371104 |
HauntedKnight |
D |
July 15, 2022, 9:49 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
15 |
2764800 |
|
|
164341814 |
CurryWOE |
D |
July 15, 2022, 4:21 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
15 |
3072000 |
|
|
164390799 |
ishrak26 |
D |
July 16, 2022, 3:48 a.m. |
OK |
GNU C++17 |
TESTS |
18 |
15 |
3174400 |
|
|
164344406 |
Eternal_Light |
D |
July 15, 2022, 4:33 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
15 |
3174400 |
|
|
164375177 |
Mine_qihang |
D |
July 15, 2022, 11:23 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
15 |
3379200 |
|
|
164398560 |
paradoxxd |
D |
July 16, 2022, 5:28 a.m. |
OK |
GNU C++17 |
TESTS |
18 |
15 |
3481600 |
|
|
164399465 |
paradoxxd |
D |
July 16, 2022, 5:37 a.m. |
OK |
GNU C++17 |
TESTS |
18 |
15 |
3481600 |
|
|
164343441 |
qwynick |
D |
July 15, 2022, 4:28 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
15 |
2048000 |
|
|
164343012 |
Richw818 |
D |
July 15, 2022, 4:26 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
15 |
2764800 |
|
|
164343664 |
propane |
D |
July 15, 2022, 4:29 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
15 |
3584000 |
|
|
164368809 |
Evang |
D |
July 15, 2022, 9:02 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
15 |
3584000 |
|
|
164383224 |
Muly |
D |
July 16, 2022, 2:14 a.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
15 |
3788800 |
|
|
164381944 |
wx13479893646 |
D |
July 16, 2022, 1:56 a.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
15 |
3788800 |
|
|
164372959 |
Ali_ElMasry |
D |
July 15, 2022, 10:35 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
15 |
3788800 |
|
|
164351429 |
xlz |
D |
July 15, 2022, 5:29 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
15 |
3788800 |
|
|
164345473 |
DmitryLzr |
D |
July 15, 2022, 4:40 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
15 |
3788800 |
|
|
164383050 |
xhgua |
D |
July 16, 2022, 2:11 a.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
15 |
3788800 |
|
|
164346642 |
Ghieath |
D |
July 15, 2022, 4:48 p.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
15 |
1024000 |
|
|
164393525 |
temmieowo |
D |
July 16, 2022, 4:26 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
15 |
1024000 |
|
|
164363550 |
Mayank_Katyayan |
D |
July 15, 2022, 7:41 p.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
15 |
1536000 |
|
|
164374663 |
YadavJi69 |
D |
July 15, 2022, 11:06 p.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
15 |
2560000 |
|
|
164389877 |
bachbeo2007 |
D |
July 16, 2022, 3:36 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
15 |
2560000 |
|
|
164343514 |
SaiAryan |
D |
July 15, 2022, 4:29 p.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
15 |
2560000 |
|
|
164374745 |
Nilesh.ky |
D |
July 15, 2022, 11:09 p.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
15 |
2560000 |
|
|
164378137 |
LuluOwO |
D |
July 16, 2022, 12:46 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
15 |
3174400 |
|
|
164401671 |
Bob15324 |
D |
July 16, 2022, 6 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
15 |
3788800 |
|
|
164386078 |
AKMer |
D |
July 16, 2022, 2:52 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
15 |
3788800 |
|
|
164375254 |
0x3F |
D |
July 15, 2022, 11:25 p.m. |
OK |
Go |
TESTS |
18 |
31 |
1536000 |
|
|
164372013 |
protogrammer |
D |
July 15, 2022, 10:09 p.m. |
OK |
Go |
TESTS |
18 |
31 |
13004800 |
|
|
164374003 |
NO__OB |
D |
July 15, 2022, 10:47 p.m. |
OK |
Java 11 |
TESTS |
18 |
187 |
0 |
|
|
164341764 |
rwee1001 |
D |
July 15, 2022, 4:21 p.m. |
OK |
Java 11 |
TESTS |
18 |
187 |
0 |
|
|
164343364 |
temp98 |
D |
July 15, 2022, 4:28 p.m. |
OK |
Java 11 |
TESTS |
18 |
202 |
4710400 |
|
|
164359289 |
dunkingdonuts |
D |
July 15, 2022, 6:48 p.m. |
OK |
Java 11 |
TESTS |
18 |
202 |
9830400 |
|
|
164344238 |
OhLee |
D |
July 15, 2022, 4:32 p.m. |
OK |
Java 11 |
TESTS |
18 |
233 |
9830400 |
|
|
164388859 |
Wuya |
D |
July 16, 2022, 3:24 a.m. |
OK |
Java 11 |
TESTS |
18 |
233 |
10240000 |
|
|
164344095 |
kyaruru |
D |
July 15, 2022, 4:32 p.m. |
OK |
Java 11 |
TESTS |
18 |
249 |
5222400 |
|
|
164343300 |
QPALZM123 |
D |
July 15, 2022, 4:28 p.m. |
OK |
Java 11 |
TESTS |
18 |
249 |
11366400 |
|
|
164351096 |
1364354238zxd |
D |
July 15, 2022, 5:26 p.m. |
OK |
Java 11 |
TESTS |
18 |
264 |
10649600 |
|
|
164391578 |
mk_0380 |
D |
July 16, 2022, 3:58 a.m. |
OK |
Java 11 |
TESTS |
18 |
264 |
12902400 |
|
|
164372884 |
Longgggggggg |
D |
July 15, 2022, 10:33 p.m. |
OK |
Java 17 |
TESTS |
18 |
202 |
4096000 |
|
|
164399094 |
soumit915 |
D |
July 16, 2022, 5:33 a.m. |
OK |
Java 17 |
TESTS |
18 |
295 |
819200 |
|
|
164358225 |
WalrusRamen21 |
D |
July 15, 2022, 6:36 p.m. |
OK |
Java 8 |
TESTS |
18 |
124 |
2764800 |
|
|
164347861 |
HideBeyondYou |
D |
July 15, 2022, 4:57 p.m. |
OK |
Java 8 |
TESTS |
18 |
140 |
2969600 |
|
|
164357470 |
liomsv |
D |
July 15, 2022, 6:28 p.m. |
OK |
Java 8 |
TESTS |
18 |
280 |
0 |
|
|
164367454 |
UniversalAdmin |
D |
July 15, 2022, 8:40 p.m. |
OK |
Java 8 |
TESTS |
18 |
436 |
15155200 |
|
|
164385546 |
linxiaotian |
D |
July 16, 2022, 2:46 a.m. |
OK |
Kotlin 1.4 |
TESTS |
18 |
202 |
12083200 |
|
|
164342289 |
nikuradze2006 |
D |
July 15, 2022, 4:23 p.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
61 |
5939200 |
|
|
164393778 |
TemporalBloom |
D |
July 16, 2022, 4:29 a.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
62 |
5222400 |
|
|
164371515 |
laym0n |
D |
July 15, 2022, 9:59 p.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
62 |
6041600 |
|
|
164343322 |
FishAndCat |
D |
July 15, 2022, 4:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
139 |
2048000 |
|
|
164344336 |
1_2_3_4_5_9 |
D |
July 15, 2022, 4:33 p.m. |
OK |
PyPy 2 |
TESTS |
18 |
187 |
17100800 |
|
|
164346322 |
Noureldin |
D |
July 15, 2022, 4:46 p.m. |
OK |
PyPy 3 |
TESTS |
18 |
155 |
10752000 |
|
|
164345028 |
sushmanth.dampur8780 |
D |
July 15, 2022, 4:37 p.m. |
OK |
PyPy 3 |
TESTS |
18 |
233 |
9523200 |
|
|
164388918 |
rajeshpenugonda6 |
D |
July 16, 2022, 3:25 a.m. |
OK |
PyPy 3 |
TESTS |
18 |
280 |
14336000 |
|
|
164394903 |
dummy3 |
D |
July 16, 2022, 4:44 a.m. |
OK |
PyPy 3 |
TESTS |
18 |
280 |
37273600 |
|
|
164343852 |
anishde85 |
D |
July 15, 2022, 4:30 p.m. |
OK |
PyPy 3 |
TESTS |
18 |
343 |
221696000 |
|
|
164356975 |
Aksnov |
D |
July 15, 2022, 6:23 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
139 |
10547200 |
|
|
164363929 |
kimerikal |
D |
July 15, 2022, 7:46 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
155 |
10854400 |
|
|
164354832 |
biglunchdude |
D |
July 15, 2022, 6:02 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
155 |
33280000 |
|
|
164360497 |
moyung |
D |
July 15, 2022, 7:02 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
186 |
12595200 |
|
|
164388556 |
sjNxksbzj |
D |
July 16, 2022, 3:21 a.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
186 |
28569600 |
|
|
164400568 |
riroan |
D |
July 16, 2022, 5:49 a.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
187 |
29184000 |
|
|
164372636 |
NKUCristiano |
D |
July 15, 2022, 10:26 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
202 |
14438400 |
|
|
164396777 |
shiviDON |
D |
July 16, 2022, 5:08 a.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
202 |
29593600 |
|
|
164362277 |
PMiguelez |
D |
July 15, 2022, 7:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
249 |
14438400 |
|
|
164378241 |
tassei903 |
D |
July 16, 2022, 12:48 a.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
249 |
28057600 |
|
|
164379633 |
Lhohelhohehmm |
D |
July 16, 2022, 1:16 a.m. |
OK |
Python 3 |
TESTS |
18 |
233 |
7270400 |
|
|
164381106 |
BeBeBe66666 |
D |
July 16, 2022, 1:42 a.m. |
OK |
Python 3 |
TESTS |
18 |
234 |
7270400 |
|
|
164390411 |
20020meb1331 |
D |
July 16, 2022, 3:43 a.m. |
OK |
Python 3 |
TESTS |
18 |
248 |
7270400 |
|
|
164347896 |
technuts01 |
D |
July 15, 2022, 4:57 p.m. |
OK |
Python 3 |
TESTS |
18 |
265 |
921600 |
|
|
164342446 |
xttt |
D |
July 15, 2022, 4:24 p.m. |
OK |
Rust 2021 |
TESTS |
18 |
15 |
1024000 |
|
|
164342117 |
xttt |
D |
July 15, 2022, 4:22 p.m. |
OK |
Rust 2021 |
TESTS |
18 |
15 |
1024000 |
|
|
164342932 |
Thallium54 |
D |
July 15, 2022, 4:26 p.m. |
OK |
Rust 2021 |
TESTS |
18 |
15 |
3788800 |
|
|
164377789 |
magnus.hegdahl |
D |
July 16, 2022, 12:39 a.m. |
OK |
Rust 2021 |
TESTS |
18 |
15 |
7168000 |
|
|
164361602 |
bjin |
D |
July 15, 2022, 7:16 p.m. |
OK |
Rust 2021 |
TESTS |
18 |
31 |
6553600 |
|
|
164354227 |
bjin |
D |
July 15, 2022, 5:56 p.m. |
OK |
Rust 2021 |
TESTS |
18 |
31 |
6553600 |
|
|
remove filters
Back to search problems