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'A sequence of round and square brackets is given. You can change the sequence by performing the following operations: The operations can be performed in any order any number of times. You are given a string s of the length n and q queries of the type "l r" where 1 <= l < r <= n . For every substring s[l ... r] , find the minimum cost to pay to make it a correct bracket sequence. It is guaranteed that the substring s[l ... r] has an even length. The queries must be processed independently, i.e. the changes made in the string for the answer to a question i don 't affect the queries j ( j > i ). In other words, for every query, the substring s[l ... r] is given from the initially given string s . A correct bracket sequence is a sequence that can be built according the following rules: E.g. the sequences "", "(()[])", "[()()]()" and "(())()" are correct bracket sequences whereas "(", "[(])" and ")))" are not. The first line contains one integer t ( 1 <= t <= 100 ) -- the number of test cases. Then t test cases follow. For each test case, the first line contains a non-empty string s containing only round ( '( ', ') ') and square ( '[ ', '] ') brackets. The length of the string doesn 't exceed 10^6 . The string contains at least 2 characters. The second line contains one integer q ( 1 <= q <= 2 cdot 10^5 ) -- the number of queries. Then q lines follow, each of them contains two integers l and r ( 1 <= l < r <= n where n is the length of s ). It is guaranteed that the substring s[l ... r] has even length. It is guaranteed that the sum of the lengths of all strings given in all test cases doesn 't exceed 10^6 . The sum of all q given in all test cases doesn 't exceed 2 cdot 10^5 . For each test case output in a separate line for each query one integer x ( x ge 0 ) -- the minimum cost t'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
131946321 |
AC__hunter |
G |
Oct. 14, 2021, 2:05 p.m. |
OK |
GNU C++14 |
TESTS |
17 |
124 |
5017600 |
|
|
131958488 |
Newusers |
G |
Oct. 14, 2021, 4:11 p.m. |
OK |
GNU C++14 |
TESTS |
17 |
139 |
5017600 |
|
|
131940692 |
Steve1234 |
G |
Oct. 14, 2021, 1:15 p.m. |
OK |
GNU C++14 |
TESTS |
17 |
139 |
5017600 |
|
|
131909047 |
_zzi_ |
G |
Oct. 14, 2021, 8:05 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
139 |
5017600 |
|
|
131918947 |
actypedef |
G |
Oct. 14, 2021, 9:55 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
139 |
10035200 |
|
|
131962565 |
shengdakindergarten |
G |
Oct. 14, 2021, 4:59 p.m. |
OK |
GNU C++14 |
TESTS |
17 |
140 |
9011200 |
|
|
131934693 |
luogu_bot2 |
G |
Oct. 14, 2021, 12:25 p.m. |
OK |
GNU C++14 |
TESTS |
17 |
140 |
9011200 |
|
|
131989133 |
walk_alone |
G |
Oct. 15, 2021, 3:18 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
155 |
5017600 |
|
|
131942150 |
Mohd_Faisal |
G |
Oct. 14, 2021, 1:28 p.m. |
OK |
GNU C++14 |
TESTS |
17 |
155 |
6144000 |
|
|
131984965 |
loideptrai1 |
G |
Oct. 15, 2021, 1:21 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
155 |
10649600 |
|
|
131913466 |
WaAccept |
G |
Oct. 14, 2021, 8:56 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
93 |
9113600 |
|
|
131957411 |
36iq |
G |
Oct. 14, 2021, 3:59 p.m. |
OK |
GNU C++17 |
TESTS |
17 |
139 |
9011200 |
|
|
131909579 |
geruome |
G |
Oct. 14, 2021, 8:10 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
140 |
5222400 |
|
|
131907414 |
Acoconut |
G |
Oct. 14, 2021, 7:48 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
140 |
6144000 |
|
|
131993480 |
AWuniverse |
G |
Oct. 15, 2021, 5 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
140 |
9011200 |
|
|
131908165 |
yizhiyezi |
G |
Oct. 14, 2021, 7:56 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
140 |
10035200 |
|
|
131907854 |
Acoconut |
G |
Oct. 14, 2021, 7:53 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
140 |
10035200 |
|
|
131955048 |
ash_98 |
G |
Oct. 14, 2021, 3:35 p.m. |
OK |
GNU C++17 |
TESTS |
17 |
140 |
13004800 |
|
|
131938528 |
Mazaalai |
G |
Oct. 14, 2021, 12:57 p.m. |
OK |
GNU C++17 |
TESTS |
17 |
155 |
5529600 |
|
|
131954364 |
mehtaji |
G |
Oct. 14, 2021, 3:28 p.m. |
OK |
GNU C++17 |
TESTS |
17 |
155 |
5632000 |
|
|
131962519 |
feicheng_ |
G |
Oct. 14, 2021, 4:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
46 |
10035200 |
|
|
131953923 |
kitsune |
G |
Oct. 14, 2021, 3:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
109 |
10137600 |
|
|
131990215 |
moyan1082 |
G |
Oct. 15, 2021, 3:45 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
124 |
5017600 |
|
|
131944389 |
spartanes |
G |
Oct. 14, 2021, 1:48 p.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
124 |
6144000 |
|
|
131904546 |
OleschY |
G |
Oct. 14, 2021, 7:21 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
124 |
6144000 |
|
|
131957078 |
alif_cse_ju |
G |
Oct. 14, 2021, 3:55 p.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
124 |
9011200 |
|
|
131922919 |
shjohw12 |
G |
Oct. 14, 2021, 10:36 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
124 |
9011200 |
|
|
131963951 |
kevinyang |
G |
Oct. 14, 2021, 5:16 p.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
124 |
10137600 |
|
|
131945522 |
vk48962713 |
G |
Oct. 14, 2021, 1:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
124 |
10137600 |
|
|
131929383 |
alwyn |
G |
Oct. 14, 2021, 11:36 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
124 |
10137600 |
|
|
131926202 |
TCchen |
G |
Oct. 14, 2021, 11:07 a.m. |
OK |
Java 8 |
TESTS |
17 |
670 |
7372800 |
|
|
131919143 |
ghoshashis545 |
G |
Oct. 14, 2021, 9:56 a.m. |
OK |
PyPy 3 |
TESTS |
17 |
1154 |
84377600 |
|
|
131946421 |
sh1194 |
G |
Oct. 14, 2021, 2:06 p.m. |
OK |
Python 3 |
TESTS |
17 |
1325 |
27238400 |
|
|
131945974 |
sh1194 |
G |
Oct. 14, 2021, 2:02 p.m. |
OK |
Python 3 |
TESTS |
17 |
1325 |
27238400 |
|
|
remove filters
Back to search problems