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'Sasha has two binary strings s and t of the same length n , consisting of the characters 0 and 1. There is also a computing machine that can perform two types of operations on binary strings a and b of the same length k : Sasha became interested in the following: if we consider the string a=s_ls_{l+1} ldots s_r and the string b=t_lt_{l+1} ldots t_r , what is the maximum number of 1 characters in the string a that can be obtained using the computing machine. Since Sasha is very curious but lazy, it is up to you to answer this question for several pairs (l_i, r_i) that interest him. Each test consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 10^{4} ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 2 cdot 10^5 ) -- the length of the strings s and t . The second line of each test case contains a binary string s of length n , consisting of the characters 0 and 1. The third line of each test case contains a binary string t of length n , consisting of the characters 0 and 1. The fourth line of each test case contains a single integer q ( 1 <= q <= 2 cdot 10^5 ) -- the number of queries. The i -th of the following lines contains two integers l_{i} and r_{i} ( 1 <= l_{i} <= r_{i} <= n ) -- the boundaries of the i -th pair of substrings that interest Sasha. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 and the sum of q over all test cases does not exceed 2 cdot 10^5 . For each test case, output q integers -- the answers to all queries. In the first test case: In the second test case: '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
266128614 |
Bellala |
E |
June 17, 2024, 3:26 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
171 |
1228800 |
|
|
266118507 |
int_R |
E |
June 16, 2024, 11:38 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
171 |
3276800 |
|
|
266077286 |
yanfu1009 |
E |
June 16, 2024, 2:52 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
171 |
4198400 |
|
|
266074142 |
J0hn_W1ck |
E |
June 16, 2024, 2:25 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
171 |
7065600 |
|
|
266139033 |
gwf01 |
E |
June 17, 2024, 5:55 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
171 |
8601600 |
|
|
266129204 |
ZifanWang |
E |
June 17, 2024, 3:35 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
202 |
5427200 |
|
|
266125113 |
gwf01 |
E |
June 17, 2024, 2:28 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
202 |
8192000 |
|
|
266080739 |
SriRam523 |
E |
June 16, 2024, 3:17 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
203 |
4198400 |
|
|
266137802 |
caiyuanqi |
E |
June 17, 2024, 5:40 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
234 |
5017600 |
|
|
266119390 |
Grammar_hbw |
E |
June 17, 2024, 12:05 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
234 |
14233600 |
|
|
266129419 |
rahulk736694 |
E |
June 17, 2024, 3:38 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
156 |
0 |
|
|
266103717 |
Kalki1111 |
E |
June 16, 2024, 6:44 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
156 |
0 |
|
|
266117752 |
FzArK |
E |
June 16, 2024, 11:14 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
156 |
307200 |
|
|
266117702 |
sg0071729 |
E |
June 16, 2024, 11:13 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
156 |
4198400 |
|
|
266106306 |
bera_474 |
E |
June 16, 2024, 7:16 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
156 |
4198400 |
|
|
266106120 |
don_2004 |
E |
June 16, 2024, 7:14 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
156 |
4198400 |
|
|
266122843 |
Prerak_7108 |
E |
June 17, 2024, 1:40 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
171 |
0 |
|
|
266106041 |
don_2004 |
E |
June 16, 2024, 7:13 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
171 |
0 |
|
|
266066364 |
itsgit |
E |
June 16, 2024, 1:28 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
171 |
0 |
|
|
266066314 |
nebirex525 |
E |
June 16, 2024, 1:28 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
171 |
0 |
|
|
266108059 |
schmosby |
E |
June 16, 2024, 7:41 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
124 |
0 |
|
|
266133110 |
Wind_Flute |
E |
June 17, 2024, 4:37 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
124 |
102400 |
|
|
266095735 |
mateberishvili |
E |
June 16, 2024, 5:23 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
124 |
4812800 |
|
|
266133282 |
Hitham |
E |
June 17, 2024, 4:39 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
125 |
3993600 |
|
|
266132331 |
leo_rc |
E |
June 17, 2024, 4:25 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
125 |
3993600 |
|
|
266130986 |
eggag32 |
E |
June 17, 2024, 4:02 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
125 |
4096000 |
|
|
266126176 |
T-Walker |
E |
June 17, 2024, 2:47 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
125 |
4096000 |
|
|
266109253 |
n.dak0ta |
E |
June 16, 2024, 7:58 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
125 |
4096000 |
|
|
266108487 |
shuniko |
E |
June 16, 2024, 7:46 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
125 |
4096000 |
|
|
266104267 |
Hirro |
E |
June 16, 2024, 6:50 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
125 |
9318400 |
|
|
266074381 |
amon_get |
E |
June 16, 2024, 2:27 p.m. |
OK |
GNU C11 |
TESTS |
27 |
171 |
3891200 |
|
|
266074636 |
amon_get |
E |
June 16, 2024, 2:30 p.m. |
OK |
GNU C11 |
TESTS |
27 |
906 |
3788800 |
|
|
266092036 |
rainboy |
E |
June 16, 2024, 4:50 p.m. |
OK |
GNU C11 |
TESTS |
27 |
967 |
1331200 |
|
|
266104368 |
mkah123 |
E |
June 16, 2024, 6:51 p.m. |
OK |
Java 21 |
TESTS |
27 |
437 |
716800 |
|
|
266102276 |
shaili17 |
E |
June 16, 2024, 6:27 p.m. |
OK |
Java 21 |
TESTS |
27 |
452 |
819200 |
|
|
266097858 |
Althaf_Hussain |
E |
June 16, 2024, 5:43 p.m. |
OK |
Java 21 |
TESTS |
27 |
468 |
2764800 |
|
|
266110953 |
mlangc |
E |
June 16, 2024, 8:27 p.m. |
OK |
Java 21 |
TESTS |
27 |
499 |
6860800 |
|
|
266096144 |
Suvankar |
E |
June 16, 2024, 5:27 p.m. |
OK |
Java 21 |
TESTS |
27 |
1296 |
1126400 |
|
|
266133784 |
lpychemistry |
E |
June 17, 2024, 4:47 a.m. |
OK |
Java 21 |
TESTS |
27 |
1311 |
1126400 |
|
|
266090269 |
yvbf |
E |
June 16, 2024, 4:34 p.m. |
OK |
Java 8 |
TESTS |
27 |
296 |
4096000 |
|
|
266131270 |
achyut88 |
E |
June 17, 2024, 4:08 a.m. |
OK |
Java 8 |
TESTS |
27 |
874 |
15257600 |
|
|
266091826 |
dauletomarov1130 |
E |
June 16, 2024, 4:47 p.m. |
OK |
Java 8 |
TESTS |
27 |
1265 |
0 |
|
|
266105407 |
L-S-S |
E |
June 16, 2024, 7:04 p.m. |
OK |
Kotlin 1.7 |
TESTS |
27 |
1406 |
84889600 |
|
|
266127030 |
mikeac |
E |
June 17, 2024, 3:01 a.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
327 |
15564800 |
|
|
266125520 |
mikeac |
E |
June 17, 2024, 2:35 a.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
437 |
14745600 |
|
|
266077629 |
AyuAnchor |
E |
June 16, 2024, 2:54 p.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
437 |
22937600 |
|
|
266122588 |
accelerate_nju |
E |
June 17, 2024, 1:34 a.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
468 |
18841600 |
|
|
266066889 |
vjudge1 |
E |
June 16, 2024, 1:33 p.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
468 |
19148800 |
|
|
266126497 |
ow3nL |
E |
June 17, 2024, 2:52 a.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
468 |
71065600 |
|
|
266093246 |
Alex239 |
E |
June 16, 2024, 5 p.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
593 |
58060800 |
|
|
266107598 |
golomb |
E |
June 16, 2024, 7:34 p.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
656 |
31744000 |
|
|
266073707 |
ossau_guildo |
E |
June 16, 2024, 2:21 p.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
671 |
32972800 |
|
|
266068682 |
liupengsay |
E |
June 16, 2024, 1:48 p.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
796 |
47308800 |
|
|
266067871 |
OLOGY |
E |
June 16, 2024, 1:41 p.m. |
OK |
Python 3 |
TESTS |
27 |
1234 |
78233600 |
|
|
266082793 |
OLOGY |
E |
June 16, 2024, 3:33 p.m. |
OK |
Python 3 |
TESTS |
27 |
1499 |
75571200 |
|
|
266116382 |
anatemsf |
E |
June 16, 2024, 10:31 p.m. |
OK |
Python 3 |
TESTS |
27 |
1500 |
12800000 |
|
|
266067299 |
lqtrung1998 |
E |
June 16, 2024, 1:36 p.m. |
OK |
Python 3 |
TESTS |
27 |
1500 |
18227200 |
|
|
266083961 |
OLOGY |
E |
June 16, 2024, 3:42 p.m. |
OK |
Python 3 |
TESTS |
27 |
1515 |
75571200 |
|
|
266083799 |
OLOGY |
E |
June 16, 2024, 3:41 p.m. |
OK |
Python 3 |
TESTS |
27 |
1515 |
76492800 |
|
|
266067418 |
lqtrung1998 |
E |
June 16, 2024, 1:37 p.m. |
OK |
Python 3 |
TESTS |
27 |
1531 |
19251200 |
|
|
266067132 |
lqtrung1998 |
E |
June 16, 2024, 1:35 p.m. |
OK |
Python 3 |
TESTS |
27 |
1546 |
18329600 |
|
|
266067627 |
lqtrung1998 |
E |
June 16, 2024, 1:39 p.m. |
OK |
Python 3 |
TESTS |
27 |
1562 |
18329600 |
|
|
266076035 |
BetterThanNobita |
E |
June 16, 2024, 2:41 p.m. |
OK |
Rust 2021 |
TESTS |
27 |
93 |
4198400 |
|
|
266118600 |
M1ngXu |
E |
June 16, 2024, 11:40 p.m. |
OK |
Rust 2021 |
TESTS |
27 |
124 |
3891200 |
|
|
266108979 |
kingcabrams |
E |
June 16, 2024, 7:54 p.m. |
OK |
Rust 2021 |
TESTS |
27 |
155 |
4198400 |
|
|
remove filters
Back to search problems