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'This is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved. There are two binary strings a and b of length n (a binary string is a string consisting of symbols 0 and 1 ). In an operation, you select a prefix of a , and simultaneously invert the bits in the prefix ( 0 changes to 1 and 1 changes to 0 ) and reverse the order of the bits in the prefix. For example, if a=001011 and you select the prefix of length 3 , it becomes 011011 . Then if you select the entire string, it becomes 001001 . Your task is to transform the string a into b in at most 3n operations. It can be proved that it is always possible. The first line contains a single integer t ( 1 <= t <= 1000 ) -- the number of test cases. Next 3t lines contain descriptions of test cases. The first line of each test case contains a single integer n ( 1 <= n <= 1000 ) -- the length of the binary strings. The next two lines contain two binary strings a and b of length n . It is guaranteed that the sum of n across all test cases does not exceed 1000 . For each test case, output an integer k ( 0 <= k <= 3n ), followed by k integers p_1, ldots,p_k ( 1 <= p_i <= n ). Here k is the number of operations you use and p_i is the length of the prefix you flip in the i -th operation. In the first test case, we have 01 to 11 to 00 to 10 . In the second test case, we have 01011 to 00101 to 11101 to 01000 to 10100 to 00100 to 11100 . In the third test case, the strings are already the same. Another solution is to flip the prefix of length 2 , which will leave a unchanged. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
87544802 |
Gassa |
A1 |
July 21, 2020, 3 p.m. |
OK |
D |
TESTS |
20 |
31 |
8908800 |
|
1300 |
87541712 |
hos.lyric |
A1 |
July 21, 2020, 2:56 p.m. |
OK |
D |
TESTS |
20 |
31 |
8908800 |
|
1300 |
87539531 |
daut-dlang |
A1 |
July 21, 2020, 2:53 p.m. |
OK |
D |
TESTS |
20 |
31 |
8908800 |
|
1300 |
87530233 |
1207koo |
A1 |
July 21, 2020, 2:42 p.m. |
OK |
GNU C11 |
TESTS |
20 |
31 |
3686400 |
|
1300 |
87542940 |
about |
A1 |
July 21, 2020, 2:57 p.m. |
OK |
GNU C11 |
TESTS |
20 |
46 |
3686400 |
|
1300 |
87637333 |
CCPSDCGK |
A1 |
July 22, 2020, 5:52 a.m. |
OK |
GNU C++11 |
TESTS |
20 |
15 |
3686400 |
|
1300 |
87549315 |
ChocolatePotato |
A1 |
July 21, 2020, 3:07 p.m. |
OK |
GNU C++11 |
TESTS |
20 |
15 |
3891200 |
|
1300 |
87634541 |
Nyse |
A1 |
July 22, 2020, 5:14 a.m. |
OK |
GNU C++11 |
TESTS |
20 |
15 |
3993600 |
|
1300 |
87616201 |
cslives |
A1 |
July 21, 2020, 9:37 p.m. |
OK |
GNU C++11 |
TESTS |
20 |
15 |
3993600 |
|
1300 |
87534876 |
LJC00118 |
A1 |
July 21, 2020, 2:47 p.m. |
OK |
GNU C++11 |
TESTS |
20 |
15 |
4096000 |
|
1300 |
87534022 |
duality |
A1 |
July 21, 2020, 2:46 p.m. |
OK |
GNU C++11 |
TESTS |
20 |
15 |
4096000 |
|
1300 |
87538896 |
Alpha_Q |
A1 |
July 21, 2020, 2:52 p.m. |
OK |
GNU C++11 |
TESTS |
20 |
15 |
4096000 |
|
1300 |
87544402 |
Wall_breaker |
A1 |
July 21, 2020, 2:59 p.m. |
OK |
GNU C++11 |
TESTS |
20 |
15 |
4096000 |
|
1300 |
87558311 |
DarkoLoveRuby |
A1 |
July 21, 2020, 3:22 p.m. |
OK |
GNU C++11 |
TESTS |
20 |
15 |
4710400 |
|
1300 |
87621582 |
wyq728728 |
A1 |
July 22, 2020, 12:34 a.m. |
OK |
GNU C++11 |
TESTS |
20 |
15 |
4915200 |
|
1300 |
87552392 |
casperwang |
A1 |
July 21, 2020, 3:12 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
3788800 |
|
1300 |
87637227 |
chestalathi2000 |
A1 |
July 22, 2020, 5:51 a.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
3891200 |
|
1300 |
87560876 |
stefanbalaz2 |
A1 |
July 21, 2020, 3:26 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
3891200 |
|
1300 |
87547138 |
Dranoel321 |
A1 |
July 21, 2020, 3:03 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
3891200 |
|
1300 |
87544665 |
marcOS |
A1 |
July 21, 2020, 3 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
3891200 |
|
1300 |
87540604 |
ManavJ07 |
A1 |
July 21, 2020, 2:54 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
3891200 |
|
1300 |
87539721 |
maester |
A1 |
July 21, 2020, 2:53 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
3891200 |
|
1300 |
87538872 |
hardikpandya |
A1 |
July 21, 2020, 2:52 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
3891200 |
|
1300 |
87612043 |
fyter_112 |
A1 |
July 21, 2020, 8:11 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
3891200 |
|
1300 |
87577711 |
siddhugzp |
A1 |
July 21, 2020, 4 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
3891200 |
|
1300 |
87603690 |
Leonardo_Paes |
A1 |
July 21, 2020, 6:20 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
15 |
3891200 |
|
1300 |
87582958 |
bansals888 |
A1 |
July 21, 2020, 4:12 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
15 |
3891200 |
|
1300 |
87540393 |
07_2018 |
A1 |
July 21, 2020, 2:54 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
30 |
3788800 |
|
1300 |
87556498 |
vekarpov |
A1 |
July 21, 2020, 3:19 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
30 |
3788800 |
|
1300 |
87549720 |
curly_braces |
A1 |
July 21, 2020, 3:07 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
30 |
3788800 |
|
1300 |
87534954 |
nightlight |
A1 |
July 21, 2020, 2:47 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
30 |
3788800 |
|
1300 |
87534131 |
J_B_Y |
A1 |
July 21, 2020, 2:46 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
30 |
3788800 |
|
1300 |
87531108 |
Unsterblicher_Geist |
A1 |
July 21, 2020, 2:43 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
30 |
3788800 |
|
1300 |
87530450 |
YJU |
A1 |
July 21, 2020, 2:43 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
30 |
3788800 |
|
1300 |
87620431 |
Salim_Shebli |
A1 |
July 21, 2020, 11:51 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
30 |
3891200 |
|
1300 |
87547717 |
cuom1999 |
A1 |
July 21, 2020, 3:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
15 |
4300800 |
|
1300 |
87541139 |
emorgan5289 |
A1 |
July 21, 2020, 2:55 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
15 |
4300800 |
|
1300 |
87541084 |
donbasta |
A1 |
July 21, 2020, 2:55 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
15 |
4300800 |
|
1300 |
87540569 |
WeakestTopology |
A1 |
July 21, 2020, 2:54 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
15 |
4300800 |
|
1300 |
87537430 |
Rahul |
A1 |
July 21, 2020, 2:50 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
15 |
4300800 |
|
1300 |
87530461 |
achvanov |
A1 |
July 21, 2020, 2:43 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
15 |
4300800 |
|
1300 |
87529561 |
Mip182 |
A1 |
July 21, 2020, 2:42 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
15 |
4300800 |
|
1300 |
87604356 |
hubz |
A1 |
July 21, 2020, 6:27 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
15 |
4300800 |
|
1300 |
87548032 |
GRT_2018 |
A1 |
July 21, 2020, 3:05 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
15 |
4300800 |
|
1300 |
87633956 |
triple__a |
A1 |
July 22, 2020, 5:05 a.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
15 |
4403200 |
|
1300 |
87610793 |
meooow |
A1 |
July 21, 2020, 7:50 p.m. |
OK |
Go |
TESTS |
20 |
46 |
10854400 |
|
1300 |
87540950 |
Xylenox |
A1 |
July 21, 2020, 2:55 p.m. |
OK |
Go |
TESTS |
20 |
46 |
10956800 |
|
1300 |
87545874 |
mphillotry |
A1 |
July 21, 2020, 3:01 p.m. |
OK |
Java 11 |
TESTS |
20 |
187 |
23859200 |
|
1300 |
87539485 |
cirno3153 |
A1 |
July 21, 2020, 2:53 p.m. |
OK |
Java 11 |
TESTS |
20 |
187 |
23961600 |
|
1300 |
87532853 |
PizzaLovers007 |
A1 |
July 21, 2020, 2:45 p.m. |
OK |
Java 11 |
TESTS |
20 |
202 |
23756800 |
|
1300 |
87537258 |
awesomelemonade |
A1 |
July 21, 2020, 2:50 p.m. |
OK |
Java 11 |
TESTS |
20 |
311 |
23859200 |
|
1300 |
87527731 |
uwi |
A1 |
July 21, 2020, 2:41 p.m. |
OK |
Java 11 |
TESTS |
20 |
327 |
24064000 |
|
1300 |
87550697 |
ijxjdjd |
A1 |
July 21, 2020, 3:09 p.m. |
OK |
Java 8 |
TESTS |
20 |
108 |
20377600 |
|
1300 |
87539233 |
Failure |
A1 |
July 21, 2020, 2:52 p.m. |
OK |
Java 8 |
TESTS |
20 |
109 |
20377600 |
|
1300 |
87551944 |
NewtScamander |
A1 |
July 21, 2020, 3:11 p.m. |
OK |
Java 8 |
TESTS |
20 |
124 |
20377600 |
|
1300 |
87541604 |
procrastinate7 |
A1 |
July 21, 2020, 2:55 p.m. |
OK |
Java 8 |
TESTS |
20 |
124 |
20377600 |
|
1300 |
87539971 |
robinz62 |
A1 |
July 21, 2020, 2:53 p.m. |
OK |
Java 8 |
TESTS |
20 |
124 |
20377600 |
|
1300 |
87535583 |
holeguma |
A1 |
July 21, 2020, 2:48 p.m. |
OK |
Java 8 |
TESTS |
20 |
124 |
20377600 |
|
1300 |
87627265 |
nitink999 |
A1 |
July 22, 2020, 2:59 a.m. |
OK |
Java 8 |
TESTS |
20 |
124 |
20480000 |
|
1300 |
87597488 |
Hemose |
A1 |
July 21, 2020, 5:30 p.m. |
OK |
Java 8 |
TESTS |
20 |
124 |
20480000 |
|
1300 |
87579394 |
barakraganosungam |
A1 |
July 21, 2020, 4:03 p.m. |
OK |
Java 8 |
TESTS |
20 |
124 |
20480000 |
|
1300 |
87541158 |
BNL |
A1 |
July 21, 2020, 2:55 p.m. |
OK |
Java 8 |
TESTS |
20 |
124 |
20480000 |
|
1300 |
87537069 |
ekaerovets |
A1 |
July 21, 2020, 2:49 p.m. |
OK |
Kotlin |
TESTS |
20 |
124 |
20787200 |
|
1300 |
87542556 |
Hakiobo |
A1 |
July 21, 2020, 2:57 p.m. |
OK |
Kotlin |
TESTS |
20 |
124 |
20889600 |
|
1300 |
87530174 |
Tlatoani |
A1 |
July 21, 2020, 2:42 p.m. |
OK |
Kotlin |
TESTS |
20 |
124 |
21708800 |
|
1300 |
87625877 |
Spheniscine |
A1 |
July 22, 2020, 2:30 a.m. |
OK |
Kotlin |
TESTS |
20 |
124 |
22323200 |
|
1300 |
87542274 |
golions |
A1 |
July 21, 2020, 2:56 p.m. |
OK |
Kotlin |
TESTS |
20 |
155 |
21708800 |
|
1300 |
87626131 |
Spheniscine |
A1 |
July 22, 2020, 2:35 a.m. |
OK |
Kotlin |
TESTS |
20 |
155 |
22323200 |
|
1300 |
87547451 |
batkhuyag |
A1 |
July 21, 2020, 3:04 p.m. |
OK |
Kotlin |
TESTS |
20 |
170 |
21708800 |
|
1300 |
87535417 |
mban259 |
A1 |
July 21, 2020, 2:48 p.m. |
OK |
Mono C# |
TESTS |
20 |
62 |
8908800 |
|
1300 |
87544849 |
keymoon |
A1 |
July 21, 2020, 3 p.m. |
OK |
Mono C# |
TESTS |
20 |
77 |
12595200 |
|
1300 |
87533157 |
Yupiteru |
A1 |
July 21, 2020, 2:45 p.m. |
OK |
Mono C# |
TESTS |
20 |
77 |
15462400 |
|
1300 |
87533977 |
terry_u16 |
A1 |
July 21, 2020, 2:46 p.m. |
OK |
Mono C# |
TESTS |
20 |
92 |
13004800 |
|
1300 |
87540693 |
EmK |
A1 |
July 21, 2020, 2:54 p.m. |
OK |
Mono C# |
TESTS |
20 |
108 |
12697600 |
|
1300 |
87605606 |
kupriyanov |
A1 |
July 21, 2020, 6:41 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
31 |
3686400 |
|
1300 |
87550887 |
Numbervan |
A1 |
July 21, 2020, 3:09 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
31 |
3686400 |
|
1300 |
87538387 |
Gravekper |
A1 |
July 21, 2020, 2:51 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
31 |
3686400 |
|
1300 |
87545625 |
tarattata1 |
A1 |
July 21, 2020, 3:01 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
31 |
3993600 |
|
1300 |
87628190 |
P___ |
A1 |
July 22, 2020, 3:19 a.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
31 |
4198400 |
|
1300 |
87539330 |
Pnn1337 |
A1 |
July 21, 2020, 2:52 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
31 |
4198400 |
|
1300 |
87540594 |
Baharevim |
A1 |
July 21, 2020, 2:54 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
31 |
4505600 |
|
1300 |
87531848 |
pichulia |
A1 |
July 21, 2020, 2:44 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
31 |
6758400 |
|
1300 |
87545139 |
Friska |
A1 |
July 21, 2020, 3 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
46 |
3686400 |
|
1300 |
87535333 |
P___ |
A1 |
July 21, 2020, 2:47 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
46 |
4198400 |
|
1300 |
87535537 |
pajenegod |
A1 |
July 21, 2020, 2:48 p.m. |
OK |
PyPy 2 |
TESTS |
20 |
109 |
23347200 |
|
1300 |
87536928 |
exoji2e |
A1 |
July 21, 2020, 2:49 p.m. |
OK |
PyPy 2 |
TESTS |
20 |
171 |
25702400 |
|
1300 |
87558759 |
Hitikkumar |
A1 |
July 21, 2020, 3:22 p.m. |
OK |
PyPy 2 |
TESTS |
20 |
202 |
24678400 |
|
1300 |
87561328 |
SalimAboubacar |
A1 |
July 21, 2020, 3:27 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
155 |
23244800 |
|
1300 |
87566036 |
throwawayatcoder |
A1 |
July 21, 2020, 3:35 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
171 |
22323200 |
|
1300 |
87586289 |
tanon710 |
A1 |
July 21, 2020, 4:19 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
171 |
22732800 |
|
1300 |
87533527 |
qwertz73355a |
A1 |
July 21, 2020, 2:45 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
171 |
22937600 |
|
1300 |
87547322 |
nagitaosu |
A1 |
July 21, 2020, 3:04 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
171 |
23040000 |
|
1300 |
87545778 |
jayantjain100 |
A1 |
July 21, 2020, 3:01 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
171 |
23244800 |
|
1300 |
87548404 |
neterukun |
A1 |
July 21, 2020, 3:05 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
187 |
23040000 |
|
1300 |
87536873 |
titia |
A1 |
July 21, 2020, 2:49 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
218 |
23347200 |
|
1300 |
87636966 |
kollarevanth |
A1 |
July 22, 2020, 5:47 a.m. |
OK |
PyPy 3 |
TESTS |
20 |
218 |
25497600 |
|
1300 |
87541429 |
archittect |
A1 |
July 21, 2020, 2:55 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
233 |
23244800 |
|
1300 |
87532248 |
nwi |
A1 |
July 21, 2020, 2:44 p.m. |
OK |
Python 2 |
TESTS |
20 |
187 |
6758400 |
|
1300 |
87621605 |
mkawa2 |
A1 |
July 22, 2020, 12:35 a.m. |
OK |
Python 3 |
TESTS |
20 |
108 |
6963200 |
|
1300 |
87606318 |
sudhirMTS |
A1 |
July 21, 2020, 6:49 p.m. |
OK |
Python 3 |
TESTS |
20 |
140 |
7372800 |
|
1300 |
87601015 |
ashik.mahmud |
A1 |
July 21, 2020, 5:55 p.m. |
OK |
Python 3 |
TESTS |
20 |
187 |
8294400 |
|
1300 |
87596589 |
puneeth321 |
A1 |
July 21, 2020, 5:26 p.m. |
OK |
Python 3 |
TESTS |
20 |
233 |
7987200 |
|
1300 |
87614887 |
MopKoff |
A1 |
July 21, 2020, 9:06 p.m. |
OK |
Python 3 |
TESTS |
20 |
358 |
7065600 |
|
1300 |
87543643 |
sansen |
A1 |
July 21, 2020, 2:58 p.m. |
OK |
Rust |
TESTS |
20 |
31 |
3891200 |
|
1300 |
87541993 |
cotton100pc |
A1 |
July 21, 2020, 2:56 p.m. |
OK |
Rust |
TESTS |
20 |
31 |
3993600 |
|
1300 |
87541948 |
ngtkana |
A1 |
July 21, 2020, 2:56 p.m. |
OK |
Rust |
TESTS |
20 |
31 |
4096000 |
|
1300 |
87531751 |
Russell_Emerine |
A1 |
July 21, 2020, 2:44 p.m. |
OK |
Rust |
TESTS |
20 |
46 |
3788800 |
|
1300 |
87534086 |
robostac |
A1 |
July 21, 2020, 2:46 p.m. |
OK |
Rust |
TESTS |
20 |
46 |
4300800 |
|
1300 |
remove filters
Back to search problems