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 regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1 ' and '+ ' between the original characters of the sequence. For example: Let 's define the inverse of the bracket sequence as follows: replace all brackets '( ' with ') ', and vice versa (all brackets ') ' with '( '). For example, strings "()((" and ")())" are inverses of each other. You are given a regular bracket sequence s . Calculate the number of pairs of integers (l,r) ( 1 <= l <= r <= |s| ) such that if you replace the substring of s from the l -th character to the r -th character (inclusive) with its inverse, s will still be a regular bracket sequence. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The only line of each test case contains a non-empty regular bracket sequence; it consists only of characters '( ' and/or ') '. Additional constraint on the input: the total length of the regular bracket sequences over all test cases doesn 't exceed 2 cdot 10^5 . For each test case, print a single integer -- the number of pairs (l,r) meeting the conditions from the statement. In the first example, there is only one pair: In the second example, there are no pairs. In the third example, there are three pairs: '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
263509928 |
og.kostya |
D |
May 31, 2024, 2:10 p.m. |
OK |
C# 10 |
TESTS |
24 |
202 |
30822400 |
|
|
263388218 |
Wrong_Answer_on_test_99 |
D |
May 30, 2024, 9:28 p.m. |
OK |
C# 10 |
TESTS |
24 |
687 |
33280000 |
|
|
263407766 |
karamkontar |
D |
May 31, 2024, 4:17 a.m. |
OK |
C# 10 |
TESTS |
24 |
905 |
40345600 |
|
|
263408223 |
karamkontar |
D |
May 31, 2024, 4:22 a.m. |
OK |
C# 10 |
TESTS |
24 |
906 |
41267200 |
|
|
263570702 |
namtao97 |
D |
June 1, 2024, 3:58 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
24 |
46 |
921600 |
|
|
263422479 |
paramec1um |
D |
May 31, 2024, 6:35 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
24 |
46 |
3276800 |
|
|
263407344 |
Algorysh |
D |
May 31, 2024, 4:11 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
24 |
61 |
204800 |
|
|
263572714 |
TomGreen |
D |
June 1, 2024, 4:22 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
24 |
61 |
1024000 |
|
|
263626952 |
NJX4122 |
D |
June 1, 2024, 12:12 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
24 |
61 |
32051200 |
|
|
263443151 |
tryandtryagain |
D |
May 31, 2024, 9:35 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
24 |
62 |
3174400 |
|
|
263551844 |
Leeda |
D |
May 31, 2024, 9:27 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
24 |
77 |
0 |
|
|
263640809 |
Kent530 |
D |
June 1, 2024, 2:14 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
24 |
77 |
204800 |
|
|
263566420 |
OIDragon |
D |
June 1, 2024, 3:02 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
24 |
93 |
0 |
|
|
263590012 |
mamion |
D |
June 1, 2024, 7:14 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
24 |
93 |
102400 |
|
|
263424082 |
flashmt |
D |
May 31, 2024, 6:47 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
24 |
46 |
0 |
|
|
263419882 |
rishendraT |
D |
May 31, 2024, 6:15 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
24 |
46 |
0 |
|
|
263407733 |
wangpaopao1 |
D |
May 31, 2024, 4:16 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
24 |
46 |
0 |
|
|
263400996 |
Bonelight |
D |
May 31, 2024, 2:45 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
24 |
46 |
0 |
|
|
263398281 |
lambour |
D |
May 31, 2024, 1:53 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
24 |
46 |
0 |
|
|
263579632 |
wasso |
D |
June 1, 2024, 5:43 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
24 |
46 |
1638400 |
|
|
263422687 |
SachanSagar |
D |
May 31, 2024, 6:37 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
24 |
46 |
1638400 |
|
|
263578712 |
wasso |
D |
June 1, 2024, 5:34 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
24 |
46 |
1740800 |
|
|
263427602 |
yumingsk |
D |
May 31, 2024, 7:15 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
24 |
61 |
0 |
|
|
263420625 |
0x3ea |
D |
May 31, 2024, 6:21 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
24 |
61 |
0 |
|
|
263412026 |
ntxyl |
D |
May 31, 2024, 5:02 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
24 |
46 |
102400 |
|
|
263690261 |
N_z__ |
D |
June 2, 2024, 1:38 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
24 |
46 |
204800 |
|
|
263420325 |
TheRedStone |
D |
May 31, 2024, 6:18 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
24 |
46 |
3276800 |
|
|
263399927 |
pray4u |
D |
May 31, 2024, 2:26 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
24 |
46 |
4812800 |
|
|
263625631 |
divanik |
D |
June 1, 2024, 12:01 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
24 |
46 |
100249600 |
|
|
263406072 |
KluydQ |
D |
May 31, 2024, 3:55 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
24 |
46 |
104243200 |
|
|
263588464 |
tiger_34 |
D |
June 1, 2024, 7:01 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
24 |
61 |
0 |
|
|
263552040 |
abdalrahem.r.dado |
D |
May 31, 2024, 9:31 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
24 |
61 |
0 |
|
|
263404451 |
tyr0Whiz |
D |
May 31, 2024, 3:34 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
24 |
61 |
0 |
|
|
263584229 |
tiger_34 |
D |
June 1, 2024, 6:27 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
24 |
61 |
102400 |
|
|
263619092 |
Kevin_juruo_awa |
D |
June 1, 2024, 11:12 a.m. |
OK |
GNU C11 |
TESTS |
24 |
77 |
1126400 |
|
|
263617493 |
Kevin_juruo_awa |
D |
June 1, 2024, 11:01 a.m. |
OK |
GNU C11 |
TESTS |
24 |
77 |
1126400 |
|
|
263610018 |
Kevin_juruo_awa |
D |
June 1, 2024, 10 a.m. |
OK |
GNU C11 |
TESTS |
24 |
92 |
1126400 |
|
|
263623925 |
Kevin_juruo_awa |
D |
June 1, 2024, 11:48 a.m. |
OK |
GNU C11 |
TESTS |
24 |
93 |
1126400 |
|
|
263694716 |
nguyenquocthao00 |
D |
June 2, 2024, 3:20 a.m. |
OK |
Go |
TESTS |
24 |
77 |
7987200 |
|
|
263694472 |
nguyenquocthao00 |
D |
June 2, 2024, 3:14 a.m. |
OK |
Go |
TESTS |
24 |
77 |
8089600 |
|
|
263395436 |
79209748 |
D |
May 31, 2024, 12:43 a.m. |
OK |
Go |
TESTS |
24 |
265 |
54579200 |
|
|
263555899 |
dzhi |
D |
May 31, 2024, 11:09 p.m. |
OK |
Java 21 |
TESTS |
24 |
280 |
3481600 |
|
|
263395144 |
duyipeng |
D |
May 31, 2024, 12:35 a.m. |
OK |
Java 21 |
TESTS |
24 |
311 |
5529600 |
|
|
263391899 |
dzhi |
D |
May 30, 2024, 10:56 p.m. |
OK |
Java 21 |
TESTS |
24 |
405 |
17100800 |
|
|
263607034 |
dineshchandran311 |
D |
June 1, 2024, 9:34 a.m. |
OK |
Java 21 |
TESTS |
24 |
421 |
34816000 |
|
|
263686996 |
ItsLever |
D |
June 1, 2024, 11:55 p.m. |
OK |
Java 21 |
TESTS |
24 |
436 |
33382400 |
|
|
263612644 |
yang_wei |
D |
June 1, 2024, 10:23 a.m. |
OK |
Java 21 |
TESTS |
24 |
483 |
38195200 |
|
|
263395225 |
Tcpc8 |
D |
May 31, 2024, 12:37 a.m. |
OK |
Java 21 |
TESTS |
24 |
593 |
40243200 |
|
|
263400405 |
defenq |
D |
May 31, 2024, 2:35 a.m. |
OK |
Java 21 |
TESTS |
24 |
671 |
34304000 |
|
|
263399554 |
aakashattri |
D |
May 31, 2024, 2:19 a.m. |
OK |
Java 21 |
TESTS |
24 |
703 |
34099200 |
|
|
263520088 |
kasiru_69 |
D |
May 31, 2024, 3:35 p.m. |
OK |
Java 8 |
TESTS |
24 |
280 |
19865600 |
|
|
263613457 |
nomadicjuggrnaut |
D |
June 1, 2024, 10:30 a.m. |
OK |
Java 8 |
TESTS |
24 |
437 |
36659200 |
|
|
263382969 |
Yousef_Badr |
D |
May 30, 2024, 7:57 p.m. |
OK |
Java 8 |
TESTS |
24 |
968 |
18534400 |
|
|
263382924 |
faresbadr316 |
D |
May 30, 2024, 7:56 p.m. |
OK |
Java 8 |
TESTS |
24 |
1077 |
18534400 |
|
|
263400758 |
gsomani |
D |
May 31, 2024, 2:41 a.m. |
OK |
PyPy 3 |
TESTS |
24 |
202 |
5939200 |
|
|
263519544 |
khan_ali |
D |
May 31, 2024, 3:30 p.m. |
OK |
PyPy 3 |
TESTS |
24 |
453 |
13721600 |
|
|
263515230 |
liupengsay |
D |
May 31, 2024, 2:53 p.m. |
OK |
PyPy 3-64 |
TESTS |
24 |
109 |
4198400 |
|
|
263412170 |
MengxinWalkingGrass |
D |
May 31, 2024, 5:03 a.m. |
OK |
PyPy 3-64 |
TESTS |
24 |
109 |
15257600 |
|
|
263404372 |
gche |
D |
May 31, 2024, 3:33 a.m. |
OK |
PyPy 3-64 |
TESTS |
24 |
124 |
3584000 |
|
|
263414363 |
gche |
D |
May 31, 2024, 5:25 a.m. |
OK |
PyPy 3-64 |
TESTS |
24 |
124 |
3788800 |
|
|
263403859 |
smilences |
D |
May 31, 2024, 3:26 a.m. |
OK |
PyPy 3-64 |
TESTS |
24 |
124 |
4403200 |
|
|
263397917 |
_twi_nami |
D |
May 31, 2024, 1:45 a.m. |
OK |
PyPy 3-64 |
TESTS |
24 |
124 |
5222400 |
|
|
263519307 |
accelerate_nju |
D |
May 31, 2024, 3:28 p.m. |
OK |
PyPy 3-64 |
TESTS |
24 |
124 |
5939200 |
|
|
263408618 |
Your6QwQ |
D |
May 31, 2024, 4:26 a.m. |
OK |
PyPy 3-64 |
TESTS |
24 |
139 |
5324800 |
|
|
263415326 |
gche |
D |
May 31, 2024, 5:33 a.m. |
OK |
PyPy 3-64 |
TESTS |
24 |
140 |
3584000 |
|
|
263395480 |
PQ2876 |
D |
May 31, 2024, 12:45 a.m. |
OK |
PyPy 3-64 |
TESTS |
24 |
140 |
3993600 |
|
|
263383548 |
OLOGY |
D |
May 30, 2024, 8:06 p.m. |
OK |
Python 3 |
TESTS |
24 |
171 |
819200 |
|
|
263671658 |
awesomep |
D |
June 1, 2024, 6:45 p.m. |
OK |
Python 3 |
TESTS |
24 |
171 |
1638400 |
|
|
263426117 |
ag30 |
D |
May 31, 2024, 7:03 a.m. |
OK |
Python 3 |
TESTS |
24 |
171 |
1638400 |
|
|
263413131 |
NS3081992 |
D |
May 31, 2024, 5:13 a.m. |
OK |
Python 3 |
TESTS |
24 |
249 |
29184000 |
|
|
263412600 |
NS3081992 |
D |
May 31, 2024, 5:07 a.m. |
OK |
Python 3 |
TESTS |
24 |
249 |
29286400 |
|
|
263575381 |
PlaceOrientedProgrammer |
D |
June 1, 2024, 4:55 a.m. |
OK |
Rust 2021 |
TESTS |
24 |
62 |
921600 |
|
|
263590055 |
kiddoos |
D |
June 1, 2024, 7:14 a.m. |
OK |
Rust 2021 |
TESTS |
24 |
77 |
512000 |
|
|
263605883 |
M1ngXu |
D |
June 1, 2024, 9:25 a.m. |
OK |
Rust 2021 |
TESTS |
24 |
171 |
28160000 |
|
|
remove filters
Back to search problems