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'You are given a 2 x n grid filled with zeros and ones. Let the number at the intersection of the i -th row and the j -th column be a_{ij} . There is a grasshopper at the top-left cell (1, 1) that can only jump one cell right or downwards. It wants to reach the bottom-right cell (2, n) . Consider the binary string of length n+1 consisting of numbers written in cells of the path without changing their order. Your goal is to: ^ dagger If two strings s and t have the same length, then s is lexicographically smaller than t if and only if in the first position where s and t differ, the string s has a smaller element than the corresponding element in t . Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^4 ). The description of the test cases follows. The first line of each test case contains a single integer n ( 2 <= n <= 2 cdot 10^5 ). The second line of each test case contains a binary string a_{11} a_{12} ldots a_{1n} ( a_{1i} is either 0 or 1 ). The third line of each test case contains a binary string a_{21} a_{22} ldots a_{2n} ( a_{2i} is either 0 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 two lines: In the first test case, the lexicographically smallest string is mathtt{000} . There are two paths that yield this string: In the second test case, the lexicographically smallest string is mathtt{11000} . There is only one path that yields this string: '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
249027437 |
ruban |
B |
March 1, 2024, 5:09 a.m. |
OK |
FPC |
TESTS |
16 |
639 |
16076800 |
|
|
248970815 |
r1ck.sync |
B |
Feb. 29, 2024, 4:32 p.m. |
OK |
GNU C11 |
TESTS |
14 |
62 |
5632000 |
|
|
249010196 |
dheeraj_0207 |
B |
March 1, 2024, 12:51 a.m. |
OK |
GNU C11 |
TESTS |
14 |
140 |
819200 |
|
|
248986329 |
iffatul_anon |
B |
Feb. 29, 2024, 7:07 p.m. |
OK |
GNU C11 |
TESTS |
14 |
811 |
614400 |
|
|
249018628 |
M_SQRT |
B |
March 1, 2024, 3:19 a.m. |
OK |
GNU C++17 |
TESTS |
16 |
15 |
409600 |
|
|
248970006 |
Shifa_BD |
B |
Feb. 29, 2024, 4:31 p.m. |
OK |
GNU C++17 |
TESTS |
14 |
15 |
614400 |
|
|
249011171 |
DDDG |
B |
March 1, 2024, 1:10 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
15 |
614400 |
|
|
248998417 |
pragunb02 |
B |
Feb. 29, 2024, 9:01 p.m. |
OK |
GNU C++17 |
TESTS |
14 |
15 |
716800 |
|
|
248986821 |
DualRed |
B |
Feb. 29, 2024, 7:10 p.m. |
OK |
GNU C++17 |
TESTS |
14 |
15 |
716800 |
|
|
248982382 |
wackyIndian |
B |
Feb. 29, 2024, 6:45 p.m. |
OK |
GNU C++17 |
TESTS |
14 |
15 |
716800 |
|
|
249030679 |
Bright_Nut |
B |
March 1, 2024, 5:39 a.m. |
OK |
GNU C++17 |
TESTS |
16 |
15 |
716800 |
|
|
249013177 |
LOVESTONE |
B |
March 1, 2024, 1:49 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
15 |
716800 |
|
|
249009123 |
vikash_27 |
B |
March 1, 2024, 12:28 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
15 |
716800 |
|
|
248986384 |
aaryanjain112 |
B |
Feb. 29, 2024, 7:07 p.m. |
OK |
GNU C++17 |
TESTS |
14 |
15 |
921600 |
|
|
249021320 |
lhpm |
B |
March 1, 2024, 3:56 a.m. |
OK |
GNU C++17 (64) |
TESTS |
16 |
15 |
716800 |
|
|
249013602 |
Yangmrl |
B |
March 1, 2024, 1:56 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
15 |
716800 |
|
|
249011497 |
iced_T |
B |
March 1, 2024, 1:16 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
15 |
716800 |
|
|
249022406 |
Narayan247 |
B |
March 1, 2024, 4:10 a.m. |
OK |
GNU C++17 (64) |
TESTS |
16 |
15 |
716800 |
|
|
249022642 |
Ackhava |
B |
March 1, 2024, 4:13 a.m. |
OK |
GNU C++17 (64) |
TESTS |
16 |
15 |
716800 |
|
|
249026359 |
amazy |
B |
March 1, 2024, 4:57 a.m. |
OK |
GNU C++17 (64) |
TESTS |
16 |
15 |
716800 |
|
|
249017330 |
Winding. |
B |
March 1, 2024, 2:59 a.m. |
OK |
GNU C++17 (64) |
TESTS |
16 |
15 |
921600 |
|
|
249029202 |
Md_Minhaj |
B |
March 1, 2024, 5:25 a.m. |
OK |
GNU C++17 (64) |
TESTS |
16 |
15 |
921600 |
|
|
249023393 |
Yshanqian |
B |
March 1, 2024, 4:22 a.m. |
OK |
GNU C++17 (64) |
TESTS |
16 |
15 |
921600 |
|
|
249022427 |
Inverted_Tuna |
B |
March 1, 2024, 4:10 a.m. |
OK |
GNU C++17 (64) |
TESTS |
16 |
15 |
921600 |
|
|
248987959 |
Amgad_ktaya |
B |
Feb. 29, 2024, 7:19 p.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
0 |
1024000 |
|
|
249018182 |
fa45b216 |
B |
March 1, 2024, 3:12 a.m. |
OK |
GNU C++20 (64) |
TESTS |
16 |
0 |
1024000 |
|
|
249016607 |
Kidding__Ma |
B |
March 1, 2024, 2:47 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
0 |
1024000 |
|
|
249005197 |
kissna |
B |
Feb. 29, 2024, 10:58 p.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
0 |
1228800 |
|
|
248996497 |
vbutenko |
B |
Feb. 29, 2024, 8:36 p.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
0 |
1433600 |
|
|
249020135 |
Souture |
B |
March 1, 2024, 3:41 a.m. |
OK |
GNU C++20 (64) |
TESTS |
16 |
0 |
1433600 |
|
|
249023605 |
Jahidul_CSE |
B |
March 1, 2024, 4:24 a.m. |
OK |
GNU C++20 (64) |
TESTS |
16 |
0 |
1433600 |
|
|
248981382 |
Shinchan_Noharaa |
B |
Feb. 29, 2024, 6:41 p.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
0 |
1536000 |
|
|
249028801 |
SSKMF |
B |
March 1, 2024, 5:21 a.m. |
OK |
GNU C++20 (64) |
TESTS |
16 |
15 |
409600 |
|
|
249026092 |
Rhino_ |
B |
March 1, 2024, 4:54 a.m. |
OK |
GNU C++20 (64) |
TESTS |
16 |
15 |
409600 |
|
|
248997302 |
trurgot |
B |
Feb. 29, 2024, 8:46 p.m. |
OK |
Go |
TESTS |
14 |
31 |
3891200 |
|
|
249001794 |
trurgot |
B |
Feb. 29, 2024, 9:53 p.m. |
OK |
Go |
TESTS |
14 |
31 |
3891200 |
|
|
249020035 |
ajayg3059 |
B |
March 1, 2024, 3:40 a.m. |
OK |
Go |
TESTS |
16 |
46 |
4710400 |
|
|
249001587 |
polsage |
B |
Feb. 29, 2024, 9:50 p.m. |
OK |
Java 21 |
TESTS |
14 |
264 |
0 |
|
|
248992734 |
4ALL |
B |
Feb. 29, 2024, 7:59 p.m. |
OK |
Java 21 |
TESTS |
14 |
264 |
0 |
|
|
248968309 |
harsh_1806 |
B |
Feb. 29, 2024, 4:28 p.m. |
OK |
Java 21 |
TESTS |
14 |
264 |
0 |
|
|
248992396 |
santanu021 |
B |
Feb. 29, 2024, 7:55 p.m. |
OK |
Java 21 |
TESTS |
14 |
265 |
102400 |
|
|
249005735 |
koolkartik |
B |
Feb. 29, 2024, 11:09 p.m. |
OK |
Java 21 |
TESTS |
14 |
280 |
0 |
|
|
249001218 |
polsage |
B |
Feb. 29, 2024, 9:44 p.m. |
OK |
Java 21 |
TESTS |
14 |
280 |
0 |
|
|
248963378 |
prac_123 |
B |
Feb. 29, 2024, 4:18 p.m. |
OK |
Java 21 |
TESTS |
14 |
280 |
0 |
|
|
249000795 |
polsage |
B |
Feb. 29, 2024, 9:37 p.m. |
OK |
Java 21 |
TESTS |
14 |
280 |
102400 |
|
|
249013741 |
kbliu |
B |
March 1, 2024, 1:58 a.m. |
OK |
Java 21 |
TESTS |
14 |
280 |
409600 |
|
|
249025726 |
yang_wei |
B |
March 1, 2024, 4:50 a.m. |
OK |
Java 21 |
TESTS |
16 |
295 |
6758400 |
|
|
249027307 |
Mr.Numerator_007 |
B |
March 1, 2024, 5:07 a.m. |
OK |
Java 8 |
TESTS |
16 |
109 |
0 |
|
|
248984612 |
abhayrajnegi0416 |
B |
Feb. 29, 2024, 6:57 p.m. |
OK |
Java 8 |
TESTS |
14 |
124 |
0 |
|
|
249012360 |
Yousef_Badr |
B |
March 1, 2024, 1:35 a.m. |
OK |
Java 8 |
TESTS |
14 |
140 |
0 |
|
|
248964382 |
yrflxian |
B |
Feb. 29, 2024, 4:20 p.m. |
OK |
Java 8 |
TESTS |
14 |
155 |
0 |
|
|
249022571 |
coderman2004 |
B |
March 1, 2024, 4:12 a.m. |
OK |
Java 8 |
TESTS |
16 |
218 |
0 |
|
|
249021932 |
Mr_A |
B |
March 1, 2024, 4:03 a.m. |
OK |
Java 8 |
TESTS |
16 |
233 |
0 |
|
|
248971116 |
Pre_L |
B |
Feb. 29, 2024, 4:33 p.m. |
OK |
Java 8 |
TESTS |
14 |
233 |
0 |
|
|
248986647 |
Sumitsingh7 |
B |
Feb. 29, 2024, 7:09 p.m. |
OK |
Java 8 |
TESTS |
14 |
233 |
7680000 |
|
|
248986284 |
Indrajit |
B |
Feb. 29, 2024, 7:07 p.m. |
OK |
Java 8 |
TESTS |
14 |
233 |
7680000 |
|
|
248984799 |
kasiru_69 |
B |
Feb. 29, 2024, 6:58 p.m. |
OK |
Java 8 |
TESTS |
14 |
249 |
0 |
|
|
249023898 |
ved_prakash |
B |
March 1, 2024, 4:28 a.m. |
OK |
Mono C# |
TESTS |
16 |
108 |
2969600 |
|
|
248963050 |
Yjtx_fcjd |
B |
Feb. 29, 2024, 4:17 p.m. |
OK |
MS C++ 2017 |
TESTS |
14 |
78 |
1638400 |
|
|
248968321 |
Mikrukova_Ekaterina |
B |
Feb. 29, 2024, 4:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
14 |
93 |
1024000 |
|
|
249012101 |
FFFBL |
B |
March 1, 2024, 1:29 a.m. |
OK |
MS C++ 2017 |
TESTS |
14 |
93 |
1126400 |
|
|
248970639 |
danielreker |
B |
Feb. 29, 2024, 4:32 p.m. |
OK |
MS C++ 2017 |
TESTS |
14 |
108 |
819200 |
|
|
248964625 |
maximzasorin |
B |
Feb. 29, 2024, 4:20 p.m. |
OK |
PHP |
TESTS |
14 |
108 |
0 |
|
|
248994657 |
brunocalza |
B |
Feb. 29, 2024, 8:17 p.m. |
OK |
PyPy 2 |
TESTS |
14 |
311 |
17203200 |
|
|
249025587 |
Raindrops1117 |
B |
March 1, 2024, 4:49 a.m. |
OK |
PyPy 3 |
TESTS |
16 |
311 |
16793600 |
|
|
248965887 |
radhikapillai25 |
B |
Feb. 29, 2024, 4:23 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
467 |
12288000 |
|
|
249014548 |
justapasserby |
B |
March 1, 2024, 2:12 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
483 |
8806400 |
|
|
248983618 |
_vijay_rubesh213 |
B |
Feb. 29, 2024, 6:52 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
561 |
14745600 |
|
|
248969925 |
Akshar_7 |
B |
Feb. 29, 2024, 4:31 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
779 |
10137600 |
|
|
248991279 |
gardengnome |
B |
Feb. 29, 2024, 7:45 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
93 |
7372800 |
|
|
248990886 |
RobinFromTheHood |
B |
Feb. 29, 2024, 7:42 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
93 |
17920000 |
|
|
248987964 |
khalit7 |
B |
Feb. 29, 2024, 7:19 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
109 |
31641600 |
|
|
249000185 |
me6 |
B |
Feb. 29, 2024, 9:27 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
139 |
9830400 |
|
|
248985964 |
Codetic |
B |
Feb. 29, 2024, 7:05 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
139 |
14438400 |
|
|
248989463 |
RobinFromTheHood |
B |
Feb. 29, 2024, 7:30 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
139 |
16384000 |
|
|
248995216 |
Expert_by_september |
B |
Feb. 29, 2024, 8:22 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
140 |
9216000 |
|
|
249018968 |
Drought |
B |
March 1, 2024, 3:25 a.m. |
OK |
PyPy 3-64 |
TESTS |
16 |
155 |
10137600 |
|
|
249001692 |
VeryLate |
B |
Feb. 29, 2024, 9:51 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
155 |
35328000 |
|
|
249006903 |
find |
B |
Feb. 29, 2024, 11:35 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
171 |
17510400 |
|
|
248989858 |
OLOGY |
B |
Feb. 29, 2024, 7:33 p.m. |
OK |
Python 2 |
TESTS |
14 |
61 |
4198400 |
|
|
248968724 |
dodolist |
B |
Feb. 29, 2024, 4:29 p.m. |
OK |
Python 3 |
TESTS |
14 |
77 |
1126400 |
|
|
249015360 |
pennymagic156 |
B |
March 1, 2024, 2:26 a.m. |
OK |
Python 3 |
TESTS |
14 |
77 |
2867200 |
|
|
248983733 |
momoyao |
B |
Feb. 29, 2024, 6:52 p.m. |
OK |
Python 3 |
TESTS |
14 |
93 |
2150400 |
|
|
249023464 |
Asfak_Shahrier |
B |
March 1, 2024, 4:23 a.m. |
OK |
Python 3 |
TESTS |
16 |
108 |
1024000 |
|
|
248965860 |
kinchit_goyal |
B |
Feb. 29, 2024, 4:23 p.m. |
OK |
Python 3 |
TESTS |
14 |
109 |
1126400 |
|
|
249017864 |
hungvtn |
B |
March 1, 2024, 3:07 a.m. |
OK |
Python 3 |
TESTS |
16 |
124 |
1126400 |
|
|
248996804 |
DeepJ |
B |
Feb. 29, 2024, 8:40 p.m. |
OK |
Python 3 |
TESTS |
14 |
124 |
1126400 |
|
|
248966478 |
jinyiqi |
B |
Feb. 29, 2024, 4:24 p.m. |
OK |
Python 3 |
TESTS |
14 |
124 |
1126400 |
|
|
248985563 |
Wube |
B |
Feb. 29, 2024, 7:02 p.m. |
OK |
Python 3 |
TESTS |
14 |
124 |
1536000 |
|
|
248965250 |
The_Prax |
B |
Feb. 29, 2024, 4:22 p.m. |
OK |
Python 3 |
TESTS |
14 |
139 |
1126400 |
|
|
248966280 |
azryx0 |
B |
Feb. 29, 2024, 4:24 p.m. |
OK |
Rust 2021 |
TESTS |
14 |
15 |
1228800 |
|
|
248971365 |
Rajveer_100 |
B |
Feb. 29, 2024, 4:33 p.m. |
OK |
Rust 2021 |
TESTS |
14 |
15 |
3891200 |
|
|
249005194 |
thisf0xx |
B |
Feb. 29, 2024, 10:58 p.m. |
OK |
Rust 2021 |
TESTS |
14 |
124 |
1024000 |
|
|
249026886 |
a.dot |
B |
March 1, 2024, 5:03 a.m. |
OK |
Rust 2021 |
TESTS |
16 |
155 |
2764800 |
|
|
remove filters
Back to search problems