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 string s consisting of n characters. Each character of s is either 0 or 1. A substring of s is a contiguous subsequence of its characters. You have to choose two substrings of s (possibly intersecting, possibly the same, possibly non-intersecting -- just any two substrings). After choosing them, you calculate the value of the chosen pair of substrings as follows: Calculate the maximum possible value you can get, and print it in binary representation without leading zeroes. The first line contains one integer n -- the number of characters in s . The second line contains s itself, consisting of exactly n characters 0 and/or 1. All non-example tests in this problem are generated randomly: every character of s is chosen independently of other characters; for each character, the probability of it being 1 is exactly frac{1}{2} . This problem has exactly 40 tests. Tests from 1 to 3 are the examples; tests from 4 to 40 are generated randomly. In tests from 4 to 10 , n = 5 ; in tests from 11 to 20 , n = 1000 ; in tests from 21 to 40 , n = 10^6 . Hacks are forbidden in this problem. Print the maximum possible value you can get in binary representation without leading zeroes. In the first example, you can choose the substrings 11010 and 101. f(s_1) = 26 , f(s_2) = 5 , their bitwise OR is 31 , and the binary representation of 31 is 11111. In the second example, you can choose the substrings 1110010 and 11100. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
176784164 |
ssvb |
D |
Oct. 17, 2022, 5:04 p.m. |
OK |
D |
TESTS |
40 |
639 |
44339200 |
|
1700 |
176776477 |
rainboy |
D |
Oct. 17, 2022, 4:33 p.m. |
OK |
GNU C11 |
TESTS |
40 |
78 |
2969600 |
|
1700 |
176797862 |
ja1467 |
D |
Oct. 17, 2022, 6:55 p.m. |
OK |
GNU C11 |
TESTS |
40 |
78 |
11059200 |
|
1700 |
176821828 |
Leasier |
D |
Oct. 18, 2022, 2:31 a.m. |
OK |
GNU C11 |
TESTS |
40 |
3743 |
9011200 |
|
1700 |
176784344 |
ITACHII_UCHIHA |
D |
Oct. 17, 2022, 5:06 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176831445 |
efilU |
D |
Oct. 18, 2022, 5:07 a.m. |
OK |
GNU C++14 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176809308 |
Essa.26 |
D |
Oct. 17, 2022, 9:17 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176786670 |
EvilTom |
D |
Oct. 17, 2022, 5:22 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
31 |
5017600 |
|
1700 |
176829053 |
PepeTheBuilder_74 |
D |
Oct. 18, 2022, 4:33 a.m. |
OK |
GNU C++14 |
TESTS |
40 |
31 |
5120000 |
|
1700 |
176811615 |
vakhew1900 |
D |
Oct. 17, 2022, 10:04 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
46 |
3072000 |
|
1700 |
176809425 |
Essa.26 |
D |
Oct. 17, 2022, 9:18 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
46 |
3072000 |
|
1700 |
176830939 |
qyf700 |
D |
Oct. 18, 2022, 5:01 a.m. |
OK |
GNU C++14 |
TESTS |
40 |
46 |
3072000 |
|
1700 |
176811628 |
vakhew1900 |
D |
Oct. 17, 2022, 10:05 p.m. |
OK |
GNU C++14 |
TESTS |
40 |
46 |
3072000 |
|
1700 |
176827038 |
ArshAgl |
D |
Oct. 18, 2022, 4 a.m. |
OK |
GNU C++14 |
TESTS |
40 |
46 |
3072000 |
|
1700 |
176811304 |
Alightning |
D |
Oct. 17, 2022, 9:58 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
31 |
2048000 |
|
1700 |
176823096 |
peanutbutter1 |
D |
Oct. 18, 2022, 2:53 a.m. |
OK |
GNU C++17 |
TESTS |
40 |
31 |
2969600 |
|
1700 |
176828775 |
Vassu05 |
D |
Oct. 18, 2022, 4:28 a.m. |
OK |
GNU C++17 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176818025 |
Hamine |
D |
Oct. 18, 2022, 1:14 a.m. |
OK |
GNU C++17 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176817375 |
XWH-A |
D |
Oct. 18, 2022, 12:59 a.m. |
OK |
GNU C++17 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176812108 |
-Un_known_ |
D |
Oct. 17, 2022, 10:17 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176808681 |
xtk_ |
D |
Oct. 17, 2022, 9:06 p.m. |
OK |
GNU C++17 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176835440 |
littlelmr |
D |
Oct. 18, 2022, 5:55 a.m. |
OK |
GNU C++17 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176829715 |
LIGHT2411 |
D |
Oct. 18, 2022, 4:42 a.m. |
OK |
GNU C++17 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176833815 |
T_Unknown |
D |
Oct. 18, 2022, 5:37 a.m. |
OK |
GNU C++17 |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176782209 |
YeYeYe |
D |
Oct. 17, 2022, 4:53 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
31 |
3584000 |
|
1700 |
176790666 |
batiay |
D |
Oct. 17, 2022, 5:51 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
31 |
4096000 |
|
1700 |
176829625 |
heibaika |
D |
Oct. 18, 2022, 4:41 a.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
31 |
4096000 |
|
1700 |
176823665 |
Lycoriss |
D |
Oct. 18, 2022, 3:03 a.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
31 |
4096000 |
|
1700 |
176816171 |
DarknessCatcher_fan |
D |
Oct. 18, 2022, 12:24 a.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
31 |
4096000 |
|
1700 |
176785087 |
suzuken_w |
D |
Oct. 17, 2022, 5:11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
31 |
4096000 |
|
1700 |
176782158 |
stan23456 |
D |
Oct. 17, 2022, 4:53 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
31 |
4096000 |
|
1700 |
176776532 |
kunal_rai |
D |
Oct. 17, 2022, 4:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
31 |
4096000 |
|
1700 |
176773491 |
therehello |
D |
Oct. 17, 2022, 4:27 p.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
31 |
4096000 |
|
1700 |
176820940 |
Jakon |
D |
Oct. 18, 2022, 2:16 a.m. |
OK |
GNU C++17 (64) |
TESTS |
40 |
31 |
5120000 |
|
1700 |
176789725 |
Arickkaa |
D |
Oct. 17, 2022, 5:44 p.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
30 |
3584000 |
|
1700 |
176810591 |
eashang1 |
D |
Oct. 17, 2022, 9:42 p.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
30 |
3584000 |
|
1700 |
176819564 |
bao_zi7 |
D |
Oct. 18, 2022, 1:48 a.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
30 |
8294400 |
|
1700 |
176775378 |
sarthak3301 |
D |
Oct. 17, 2022, 4:31 p.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176826944 |
424479543 |
D |
Oct. 18, 2022, 3:59 a.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
31 |
3072000 |
|
1700 |
176821392 |
Lhohelhohehmm |
D |
Oct. 18, 2022, 2:24 a.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
31 |
3584000 |
|
1700 |
176821375 |
LYuZ |
D |
Oct. 18, 2022, 2:23 a.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
31 |
3584000 |
|
1700 |
176817999 |
Xxuu |
D |
Oct. 18, 2022, 1:13 a.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
31 |
3584000 |
|
1700 |
176832464 |
-shirley |
D |
Oct. 18, 2022, 5:21 a.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
31 |
3584000 |
|
1700 |
176827455 |
424479543 |
D |
Oct. 18, 2022, 4:07 a.m. |
OK |
GNU C++20 (64) |
TESTS |
40 |
31 |
3584000 |
|
1700 |
176780224 |
arun07 |
D |
Oct. 17, 2022, 4:44 p.m. |
OK |
Go |
TESTS |
40 |
124 |
13824000 |
|
1700 |
176799104 |
Hasker |
D |
Oct. 17, 2022, 7:10 p.m. |
OK |
Haskell |
TESTS |
40 |
889 |
198553600 |
|
1700 |
176773430 |
N_LogN |
D |
Oct. 17, 2022, 4:27 p.m. |
OK |
Java 11 |
TESTS |
40 |
249 |
512000 |
|
1700 |
176833896 |
dhruv_07 |
D |
Oct. 18, 2022, 5:38 a.m. |
OK |
Java 11 |
TESTS |
40 |
265 |
2457600 |
|
1700 |
176829721 |
dunkingdonuts |
D |
Oct. 18, 2022, 4:42 a.m. |
OK |
Java 11 |
TESTS |
40 |
265 |
4915200 |
|
1700 |
176774275 |
agentgrey |
D |
Oct. 17, 2022, 4:29 p.m. |
OK |
Java 11 |
TESTS |
40 |
280 |
8806400 |
|
1700 |
176783465 |
kasiru_69 |
D |
Oct. 17, 2022, 5 p.m. |
OK |
Java 11 |
TESTS |
40 |
358 |
9113600 |
|
1700 |
176792242 |
wat2 |
D |
Oct. 17, 2022, 6:04 p.m. |
OK |
Java 11 |
TESTS |
40 |
358 |
27340800 |
|
1700 |
176802297 |
ETHANHUNTMI5 |
D |
Oct. 17, 2022, 7:44 p.m. |
OK |
Java 11 |
TESTS |
40 |
405 |
7782400 |
|
1700 |
176818132 |
the_unseen |
D |
Oct. 18, 2022, 1:16 a.m. |
OK |
Java 11 |
TESTS |
40 |
452 |
34201600 |
|
1700 |
176834954 |
master_xqk |
D |
Oct. 18, 2022, 5:49 a.m. |
OK |
Java 11 |
TESTS |
40 |
483 |
14233600 |
|
1700 |
176826309 |
aditya2024 |
D |
Oct. 18, 2022, 3:48 a.m. |
OK |
Java 11 |
TESTS |
40 |
607 |
25907200 |
|
1700 |
176776075 |
LeetCodeforces_Null |
D |
Oct. 17, 2022, 4:32 p.m. |
OK |
Java 17 |
TESTS |
40 |
249 |
3584000 |
|
1700 |
176787985 |
_ryan18_ |
D |
Oct. 17, 2022, 5:31 p.m. |
OK |
Java 17 |
TESTS |
40 |
280 |
7884800 |
|
1700 |
176790206 |
liomsv |
D |
Oct. 17, 2022, 5:48 p.m. |
OK |
Java 17 |
TESTS |
40 |
326 |
1024000 |
|
1700 |
176782954 |
_spiralJava_ |
D |
Oct. 17, 2022, 4:57 p.m. |
OK |
Java 17 |
TESTS |
40 |
343 |
4198400 |
|
1700 |
176773961 |
spiralJava |
D |
Oct. 17, 2022, 4:28 p.m. |
OK |
Java 17 |
TESTS |
40 |
343 |
4198400 |
|
1700 |
176787393 |
LeetCodeforces_Null |
D |
Oct. 17, 2022, 5:27 p.m. |
OK |
Java 17 |
TESTS |
40 |
374 |
3584000 |
|
1700 |
176778938 |
MrOtter |
D |
Oct. 17, 2022, 4:39 p.m. |
OK |
Java 17 |
TESTS |
40 |
374 |
4300800 |
|
1700 |
176787901 |
bthero |
D |
Oct. 17, 2022, 5:30 p.m. |
OK |
Java 17 |
TESTS |
40 |
514 |
39116800 |
|
1700 |
176834990 |
master_xqk |
D |
Oct. 18, 2022, 5:50 a.m. |
OK |
Java 17 |
TESTS |
40 |
545 |
13516800 |
|
1700 |
176772730 |
LonggHuynh |
D |
Oct. 17, 2022, 4:26 p.m. |
OK |
Java 17 |
TESTS |
40 |
576 |
44134400 |
|
1700 |
176822235 |
frey4 |
D |
Oct. 18, 2022, 2:38 a.m. |
OK |
Java 8 |
TESTS |
40 |
187 |
5222400 |
|
1700 |
176816950 |
ikillmyself |
D |
Oct. 18, 2022, 12:46 a.m. |
OK |
Java 8 |
TESTS |
40 |
202 |
4915200 |
|
1700 |
176817655 |
ikillmyself |
D |
Oct. 18, 2022, 1:05 a.m. |
OK |
Java 8 |
TESTS |
40 |
233 |
4915200 |
|
1700 |
176798296 |
invincible777 |
D |
Oct. 17, 2022, 7 p.m. |
OK |
Java 8 |
TESTS |
40 |
248 |
46796800 |
|
1700 |
176791314 |
Sourabh989 |
D |
Oct. 17, 2022, 5:56 p.m. |
OK |
Java 8 |
TESTS |
40 |
296 |
4915200 |
|
1700 |
176834928 |
master_xqk |
D |
Oct. 18, 2022, 5:49 a.m. |
OK |
Java 8 |
TESTS |
40 |
499 |
28979200 |
|
1700 |
176835059 |
master_xqk |
D |
Oct. 18, 2022, 5:50 a.m. |
OK |
Java 8 |
TESTS |
40 |
514 |
28979200 |
|
1700 |
176796910 |
deepkasana |
D |
Oct. 17, 2022, 6:46 p.m. |
OK |
Java 8 |
TESTS |
40 |
3353 |
17203200 |
|
1700 |
176773092 |
hotkey |
D |
Oct. 17, 2022, 4:26 p.m. |
OK |
Kotlin 1.6 |
TESTS |
40 |
857 |
38195200 |
|
1700 |
176800649 |
AlexandraGerasimova |
D |
Oct. 17, 2022, 7:25 p.m. |
OK |
MS C++ 2017 |
TESTS |
40 |
46 |
3174400 |
|
1700 |
176821068 |
LiuZhaocheng |
D |
Oct. 18, 2022, 2:18 a.m. |
OK |
MS C++ 2017 |
TESTS |
40 |
499 |
2457600 |
|
1700 |
176820691 |
LiuZhaocheng |
D |
Oct. 18, 2022, 2:12 a.m. |
OK |
MS C++ 2017 |
TESTS |
40 |
499 |
2457600 |
|
1700 |
176793638 |
The_New_Kid |
D |
Oct. 17, 2022, 6:16 p.m. |
OK |
PyPy 3 |
TESTS |
40 |
218 |
7782400 |
|
1700 |
176835554 |
MohamedHamed123 |
D |
Oct. 18, 2022, 5:56 a.m. |
OK |
PyPy 3 |
TESTS |
40 |
248 |
9420800 |
|
1700 |
176835840 |
0x7f_ |
D |
Oct. 18, 2022, 5:59 a.m. |
OK |
PyPy 3 |
TESTS |
40 |
249 |
8704000 |
|
1700 |
176835509 |
MohamedHamed123 |
D |
Oct. 18, 2022, 5:55 a.m. |
OK |
PyPy 3 |
TESTS |
40 |
264 |
8806400 |
|
1700 |
176788648 |
RedSpica |
D |
Oct. 17, 2022, 5:36 p.m. |
OK |
PyPy 3 |
TESTS |
40 |
421 |
13312000 |
|
1700 |
176798688 |
5hu8h |
D |
Oct. 17, 2022, 7:05 p.m. |
OK |
PyPy 3 |
TESTS |
40 |
966 |
41574400 |
|
1700 |
176800278 |
sushmanth.dampur8780 |
D |
Oct. 17, 2022, 7:21 p.m. |
OK |
PyPy 3 |
TESTS |
40 |
2791 |
101171200 |
|
1700 |
176800602 |
mrdhnv |
D |
Oct. 17, 2022, 7:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
40 |
62 |
8192000 |
|
1700 |
176795271 |
SoleProprietor |
D |
Oct. 17, 2022, 6:30 p.m. |
OK |
PyPy 3-64 |
TESTS |
40 |
62 |
8908800 |
|
1700 |
176815192 |
sjNxksbzj |
D |
Oct. 17, 2022, 11:52 p.m. |
OK |
PyPy 3-64 |
TESTS |
40 |
77 |
7065600 |
|
1700 |
176815226 |
sjNxksbzj |
D |
Oct. 17, 2022, 11:53 p.m. |
OK |
PyPy 3-64 |
TESTS |
40 |
77 |
7782400 |
|
1700 |
176785413 |
sandy_5000 |
D |
Oct. 17, 2022, 5:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
40 |
77 |
7987200 |
|
1700 |
176815155 |
sjNxksbzj |
D |
Oct. 17, 2022, 11:50 p.m. |
OK |
PyPy 3-64 |
TESTS |
40 |
77 |
8294400 |
|
1700 |
176785295 |
momoyao |
D |
Oct. 17, 2022, 5:12 p.m. |
OK |
PyPy 3-64 |
TESTS |
40 |
77 |
8704000 |
|
1700 |
176784399 |
momoyao |
D |
Oct. 17, 2022, 5:06 p.m. |
OK |
PyPy 3-64 |
TESTS |
40 |
77 |
8704000 |
|
1700 |
176784045 |
momoyao |
D |
Oct. 17, 2022, 5:04 p.m. |
OK |
PyPy 3-64 |
TESTS |
40 |
77 |
8704000 |
|
1700 |
176782752 |
momoyao |
D |
Oct. 17, 2022, 4:56 p.m. |
OK |
PyPy 3-64 |
TESTS |
40 |
77 |
8704000 |
|
1700 |
176821324 |
827821562 |
D |
Oct. 18, 2022, 2:23 a.m. |
OK |
Python 3 |
TESTS |
40 |
61 |
3481600 |
|
1700 |
176834134 |
Gayathri_1261 |
D |
Oct. 18, 2022, 5:40 a.m. |
OK |
Python 3 |
TESTS |
40 |
62 |
3276800 |
|
1700 |
176816478 |
LispWizard |
D |
Oct. 18, 2022, 12:33 a.m. |
OK |
Python 3 |
TESTS |
40 |
62 |
3276800 |
|
1700 |
176813518 |
2000031238 |
D |
Oct. 17, 2022, 10:56 p.m. |
OK |
Python 3 |
TESTS |
40 |
62 |
3276800 |
|
1700 |
176799311 |
InfernoSAlex |
D |
Oct. 17, 2022, 7:12 p.m. |
OK |
Python 3 |
TESTS |
40 |
62 |
3276800 |
|
1700 |
176796108 |
MoNasr |
D |
Oct. 17, 2022, 6:38 p.m. |
OK |
Python 3 |
TESTS |
40 |
62 |
3276800 |
|
1700 |
176794340 |
Narzullayev.S |
D |
Oct. 17, 2022, 6:22 p.m. |
OK |
Python 3 |
TESTS |
40 |
62 |
3276800 |
|
1700 |
176794246 |
Narzullayev.S |
D |
Oct. 17, 2022, 6:21 p.m. |
OK |
Python 3 |
TESTS |
40 |
62 |
3276800 |
|
1700 |
176793595 |
kunwarabhayrai12345 |
D |
Oct. 17, 2022, 6:15 p.m. |
OK |
Python 3 |
TESTS |
40 |
62 |
3276800 |
|
1700 |
176793546 |
kunwarabhayrai12345 |
D |
Oct. 17, 2022, 6:15 p.m. |
OK |
Python 3 |
TESTS |
40 |
77 |
3276800 |
|
1700 |
176825538 |
orz_liuwei |
D |
Oct. 18, 2022, 3:35 a.m. |
OK |
Rust 2021 |
TESTS |
40 |
109 |
44236800 |
|
1700 |
176774538 |
Staal |
D |
Oct. 17, 2022, 4:29 p.m. |
OK |
Rust 2021 |
TESTS |
40 |
109 |
44339200 |
|
1700 |
remove filters
Back to search problems