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'Serval has two n -bit binary integer numbers a and b . He wants to share those numbers with Toxel. Since Toxel likes the number b more, Serval decides to change a into b by some (possibly zero) operations. In an operation, Serval can choose any positive integer k between 1 and n , and change a into one of the following number: In other words, the operation moves every bit of a left or right by k positions, where the overflowed bits are removed, and the missing bits are padded with 0 . The bitwise XOR of the shift result and the original a is assigned back to a . Serval does not have much time. He wants to perform no more than n operations to change a into b . Please help him to find out an operation sequence, or determine that it is impossible to change a into b in at most n operations. You do not need to minimize the number of operations. In this problem, x oplus y denotes the bitwise XOR operation of x and y . a ll k and a gg k denote the logical left shift and logical right shift. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 2 cdot10^{3} ). The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 2 cdot10^{3} ) -- the number of bits in numbers a and b . The second and the third line of each test case contain a binary string of length n , representing a and b , respectively. The strings contain only characters 0 and 1. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot10^{3} . For each test case, if it is impossible to change a into b in at most n operations, print a single integer -1 . Otherwise, in the first line, print the number of operations m ( 0 <= m <= n ). If m>0 '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
194974346 |
Tdyx |
D |
Feb. 25, 2023, 5:03 p.m. |
OK |
C# 10 |
TESTS |
43 |
62 |
512000 |
|
|
194961041 |
Liswiera |
D |
Feb. 25, 2023, 3:44 p.m. |
OK |
C# 10 |
TESTS |
43 |
93 |
1228800 |
|
|
194976441 |
rainboy |
D |
Feb. 25, 2023, 5:17 p.m. |
OK |
GNU C11 |
TESTS |
43 |
31 |
0 |
|
|
194961427 |
chro4896 |
D |
Feb. 25, 2023, 3:45 p.m. |
OK |
GNU C11 |
TESTS |
43 |
31 |
0 |
|
|
195006063 |
vainome |
D |
Feb. 26, 2023, 1:44 a.m. |
OK |
GNU C++14 |
TESTS |
43 |
15 |
0 |
|
|
195006022 |
vainome |
D |
Feb. 26, 2023, 1:43 a.m. |
OK |
GNU C++14 |
TESTS |
43 |
15 |
0 |
|
|
194991160 |
rfhalb |
D |
Feb. 25, 2023, 7:59 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
15 |
0 |
|
|
194974633 |
XG0000 |
D |
Feb. 25, 2023, 5:05 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
15 |
0 |
|
|
194969396 |
antguz |
D |
Feb. 25, 2023, 4:15 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
15 |
0 |
|
|
195016150 |
wzc_IOI_czw |
D |
Feb. 26, 2023, 5:34 a.m. |
OK |
GNU C++14 |
TESTS |
43 |
15 |
0 |
|
|
195015293 |
nalemy |
D |
Feb. 26, 2023, 5:21 a.m. |
OK |
GNU C++14 |
TESTS |
43 |
15 |
0 |
|
|
195010016 |
Molu |
D |
Feb. 26, 2023, 3:26 a.m. |
OK |
GNU C++14 |
TESTS |
43 |
15 |
0 |
|
|
195008198 |
yyhde3301 |
D |
Feb. 26, 2023, 2:37 a.m. |
OK |
GNU C++14 |
TESTS |
43 |
15 |
0 |
|
|
195016169 |
wzc_IOI_czw |
D |
Feb. 26, 2023, 5:35 a.m. |
OK |
GNU C++14 |
TESTS |
43 |
15 |
0 |
|
|
194965280 |
igzatino |
D |
Feb. 25, 2023, 3:59 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
15 |
0 |
|
|
194963535 |
pp_orange |
D |
Feb. 25, 2023, 3:52 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
15 |
0 |
|
|
194961109 |
AA-2007 |
D |
Feb. 25, 2023, 3:44 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
15 |
0 |
|
|
194960551 |
Mtaylor |
D |
Feb. 25, 2023, 3:42 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
15 |
0 |
|
|
195009632 |
nimakanshoujixin |
D |
Feb. 26, 2023, 3:16 a.m. |
OK |
GNU C++17 |
TESTS |
43 |
15 |
0 |
|
|
194969741 |
always_windy |
D |
Feb. 25, 2023, 4:16 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
15 |
0 |
|
|
195014846 |
ChrisKim_ZHT |
D |
Feb. 26, 2023, 5:14 a.m. |
OK |
GNU C++17 |
TESTS |
43 |
15 |
102400 |
|
|
195013781 |
robertoeugenio |
D |
Feb. 26, 2023, 4:56 a.m. |
OK |
GNU C++17 |
TESTS |
43 |
15 |
102400 |
|
|
195017691 |
one_autum_leaf |
D |
Feb. 26, 2023, 5:56 a.m. |
OK |
GNU C++17 |
TESTS |
43 |
15 |
102400 |
|
|
195016995 |
Kei921 |
D |
Feb. 26, 2023, 5:47 a.m. |
OK |
GNU C++17 |
TESTS |
43 |
15 |
102400 |
|
|
194993362 |
MarcosK |
D |
Feb. 25, 2023, 8:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
15 |
0 |
|
|
195012660 |
gqf123 |
D |
Feb. 26, 2023, 4:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
15 |
0 |
|
|
195011863 |
Once_I_Liked_AGirl |
D |
Feb. 26, 2023, 4:15 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
15 |
0 |
|
|
195011514 |
Once_I_Liked_AGirl |
D |
Feb. 26, 2023, 4:05 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
15 |
0 |
|
|
195009488 |
Once_I_Liked_AGirl |
D |
Feb. 26, 2023, 3:11 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
15 |
0 |
|
|
195006660 |
wanghai673 |
D |
Feb. 26, 2023, 1:59 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
15 |
0 |
|
|
194987833 |
artcosec |
D |
Feb. 25, 2023, 7:14 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
15 |
0 |
|
|
194985103 |
Tainel. |
D |
Feb. 25, 2023, 6:41 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
15 |
0 |
|
|
194976458 |
AmirAli-Asgari |
D |
Feb. 25, 2023, 5:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
15 |
0 |
|
|
194976224 |
wakaranai |
D |
Feb. 25, 2023, 5:15 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
15 |
0 |
|
|
194969625 |
spy20051623 |
D |
Feb. 25, 2023, 4:16 p.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
0 |
0 |
|
|
194975642 |
decsp |
D |
Feb. 25, 2023, 5:11 p.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
0 |
0 |
|
|
195009694 |
xindubawukong |
D |
Feb. 26, 2023, 3:18 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
15 |
0 |
|
|
195008928 |
wangyuxuan |
D |
Feb. 26, 2023, 2:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
15 |
0 |
|
|
195007913 |
qhnana7mi |
D |
Feb. 26, 2023, 2:30 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
15 |
0 |
|
|
195006608 |
Pujx |
D |
Feb. 26, 2023, 1:58 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
15 |
0 |
|
|
195004967 |
duoluoluo |
D |
Feb. 26, 2023, 1:12 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
15 |
0 |
|
|
195001554 |
mister |
D |
Feb. 25, 2023, 11:15 p.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
15 |
0 |
|
|
195012599 |
Gats |
D |
Feb. 26, 2023, 4:32 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
15 |
0 |
|
|
195010665 |
4444nomp |
D |
Feb. 26, 2023, 3:44 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
15 |
0 |
|
|
194987242 |
NewbiePupil |
D |
Feb. 25, 2023, 7:06 p.m. |
OK |
Java 11 |
TESTS |
43 |
202 |
0 |
|
|
194975020 |
profchi |
D |
Feb. 25, 2023, 5:07 p.m. |
OK |
Java 11 |
TESTS |
43 |
218 |
0 |
|
|
194986401 |
dzhi |
D |
Feb. 25, 2023, 6:56 p.m. |
OK |
Java 11 |
TESTS |
43 |
233 |
0 |
|
|
195015791 |
Socrates1232 |
D |
Feb. 26, 2023, 5:29 a.m. |
OK |
Java 17 |
TESTS |
43 |
202 |
512000 |
|
|
194978876 |
Mamimi |
D |
Feb. 25, 2023, 5:38 p.m. |
OK |
Java 17 |
TESTS |
43 |
202 |
512000 |
|
|
194979105 |
Restricted |
D |
Feb. 25, 2023, 5:40 p.m. |
OK |
Java 17 |
TESTS |
43 |
218 |
716800 |
|
|
194986093 |
dusty.and.rusty |
D |
Feb. 25, 2023, 6:52 p.m. |
OK |
Java 17 |
TESTS |
43 |
295 |
921600 |
|
|
195010029 |
cc4414 |
D |
Feb. 26, 2023, 3:27 a.m. |
OK |
Java 8 |
TESTS |
43 |
124 |
0 |
|
|
194978600 |
harshsingla06 |
D |
Feb. 25, 2023, 5:35 p.m. |
OK |
Java 8 |
TESTS |
43 |
139 |
0 |
|
|
194993935 |
elizarov |
D |
Feb. 25, 2023, 8:43 p.m. |
OK |
Kotlin 1.7 |
TESTS |
43 |
342 |
9830400 |
|
|
194964935 |
Snoudin |
D |
Feb. 25, 2023, 3:58 p.m. |
OK |
MS C++ 2017 |
TESTS |
43 |
15 |
0 |
|
|
194983164 |
Eldies |
D |
Feb. 25, 2023, 6:20 p.m. |
OK |
MS C++ 2017 |
TESTS |
43 |
31 |
102400 |
|
|
194984683 |
aadrito |
D |
Feb. 25, 2023, 6:37 p.m. |
OK |
MS C++ 2017 |
TESTS |
43 |
62 |
0 |
|
|
194957050 |
SPD_9X2 |
D |
Feb. 25, 2023, 3:31 p.m. |
OK |
PyPy 3 |
TESTS |
43 |
218 |
9318400 |
|
|
194978082 |
mathiaswk |
D |
Feb. 25, 2023, 5:31 p.m. |
OK |
PyPy 3-64 |
TESTS |
43 |
93 |
5529600 |
|
|
194987438 |
Kita |
D |
Feb. 25, 2023, 7:09 p.m. |
OK |
PyPy 3-64 |
TESTS |
43 |
93 |
5734400 |
|
|
194990544 |
Remineva |
D |
Feb. 25, 2023, 7:51 p.m. |
OK |
PyPy 3-64 |
TESTS |
43 |
108 |
6041600 |
|
|
194960652 |
Eunha |
D |
Feb. 25, 2023, 3:42 p.m. |
OK |
PyPy 3-64 |
TESTS |
43 |
109 |
5529600 |
|
|
194980638 |
parthtotalfun |
D |
Feb. 25, 2023, 5:55 p.m. |
OK |
PyPy 3-64 |
TESTS |
43 |
171 |
7884800 |
|
|
194974973 |
zouyu9631 |
D |
Feb. 25, 2023, 5:07 p.m. |
OK |
PyPy 3-64 |
TESTS |
43 |
171 |
10035200 |
|
|
194993213 |
bronze_coder |
D |
Feb. 25, 2023, 8:31 p.m. |
OK |
PyPy 3-64 |
TESTS |
43 |
186 |
9420800 |
|
|
194976203 |
00zijian |
D |
Feb. 25, 2023, 5:15 p.m. |
OK |
PyPy 3-64 |
TESTS |
43 |
186 |
9830400 |
|
|
194965863 |
Gleefre |
D |
Feb. 25, 2023, 4:01 p.m. |
OK |
PyPy 3-64 |
TESTS |
43 |
187 |
9011200 |
|
|
194999080 |
SugoiTurtle |
D |
Feb. 25, 2023, 10:15 p.m. |
OK |
PyPy 3-64 |
TESTS |
43 |
187 |
9420800 |
|
|
194982958 |
htnhtn |
D |
Feb. 25, 2023, 6:18 p.m. |
OK |
Python 3 |
TESTS |
43 |
1294 |
1228800 |
|
|
195002650 |
liut |
D |
Feb. 25, 2023, 11:49 p.m. |
OK |
Rust 2021 |
TESTS |
43 |
15 |
102400 |
|
|
remove filters
Back to search problems