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'The differences with the easy version of this problem are highlighted in bold. A parentheses sequence is a string consisting of characters "(" and ")", for example "(()((". A balanced parentheses sequence is a parentheses sequence which can become a valid mathematical expression after inserting numbers and operations into it, for example "(()(()))". The balance of a parentheses sequence is defined as the number of opening parentheses "(" minus the number of closing parentheses ")". For example, the balance of the sequence "(()((" is 3. A balanced parentheses sequence can also be defined as a parentheses sequence with balance 0 such that each of its prefixes has a non-negative balance. We define the balanced shuffle operation that takes a parentheses sequence and returns a parentheses sequence as follows: first, for every character of the input sequence, we compute the balance of the prefix of the sequence before that character and write those down in a table together with the positions of the characters in the input sequence, for example: Prefix balance01212321Position12345678Character(()(())) Then, we sort the columns of this table in increasing order of prefix balance, breaking ties in decreasing order of position. In the above example, we get: Prefix balance01112223Position18427536Character()(()()) The last row of this table forms another parentheses sequence, in this case "()(()())". This sequence is called the result of applying the balanced shuffle operation to the input sequence, or in short just the balanced shuffle of the input sequence. Surprisingly, it turns out that the balanced shuffle of any balanced parentheses sequence is always another balanced parentheses sequence (we will omit the proof for brevity). Even more surprisingly, the balanced shuffles of two different balanced parentheses sequences are always different, therefore the balanced shuffle operation is a bijection on the set of balanced parentheses sequences of any given length (we '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
259587640 |
kumaranish |
A2 |
May 5, 2024, 5:44 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
46 |
0 |
|
2400 |
262036976 |
Leeda |
A2 |
May 21, 2024, 2:54 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
46 |
102400 |
|
2400 |
260990348 |
sell_gram_wind |
A2 |
May 15, 2024, 12:51 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
61 |
0 |
|
2400 |
261257655 |
Kimi_Arthur |
A2 |
May 16, 2024, 10:33 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
61 |
512000 |
|
2400 |
259812377 |
waffiqmaaroja1998 |
A2 |
May 7, 2024, 12:43 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
62 |
102400 |
|
2400 |
259649931 |
LaMatematica14 |
A2 |
May 5, 2024, 3:09 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
77 |
0 |
|
2400 |
260246384 |
lianhao |
A2 |
May 10, 2024, 11:56 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
77 |
102400 |
|
2400 |
263583927 |
phirtheta |
A2 |
June 1, 2024, 6:24 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
77 |
14540800 |
|
2400 |
263617252 |
candy0014 |
A2 |
June 1, 2024, 10:59 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
27 |
77 |
22118400 |
|
2400 |
262895938 |
v20481A5432 |
A2 |
May 27, 2024, 2:37 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
46 |
0 |
|
2400 |
260047130 |
moamrmousa444 |
A2 |
May 8, 2024, 8:29 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
46 |
0 |
|
2400 |
259959580 |
2210080040 |
A2 |
May 8, 2024, 6:50 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
46 |
0 |
|
2400 |
259894155 |
freakin23 |
A2 |
May 7, 2024, 3:11 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
46 |
0 |
|
2400 |
259712373 |
is-that-kt |
A2 |
May 6, 2024, 6:46 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
46 |
0 |
|
2400 |
259648230 |
Milind-Palaria |
A2 |
May 5, 2024, 2:53 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
46 |
0 |
|
2400 |
259544984 |
sujayawale125 |
A2 |
May 4, 2024, 6:02 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
46 |
0 |
|
2400 |
259497537 |
911Boom Yzm007 |
A2 |
May 4, 2024, 11:05 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
46 |
0 |
|
2400 |
260990364 |
MIKEFENG |
A2 |
May 15, 2024, 12:52 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
46 |
102400 |
|
2400 |
260595656 |
topcoder815 |
A2 |
May 12, 2024, 1:11 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
27 |
46 |
1228800 |
|
2400 |
263110630 |
Engineer |
A2 |
May 29, 2024, 8:23 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
46 |
0 |
|
2400 |
261146867 |
nanika00 |
A2 |
May 16, 2024, 5:54 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
46 |
0 |
|
2400 |
261107405 |
pride_._ |
A2 |
May 15, 2024, 9:58 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
46 |
0 |
|
2400 |
261075809 |
AinazikBa |
A2 |
May 15, 2024, 3:37 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
46 |
0 |
|
2400 |
260953413 |
Tamora |
A2 |
May 14, 2024, 4:11 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
46 |
0 |
|
2400 |
260952244 |
Gondozu |
A2 |
May 14, 2024, 4:02 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
46 |
0 |
|
2400 |
260923295 |
2288 |
A2 |
May 14, 2024, 12:12 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
46 |
0 |
|
2400 |
260727545 |
EthanKim8683 |
A2 |
May 13, 2024, 2:53 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
46 |
0 |
|
2400 |
260703907 |
36champ |
A2 |
May 12, 2024, 6:39 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
46 |
0 |
|
2400 |
260692495 |
Ditamin |
A2 |
May 12, 2024, 4:39 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
27 |
46 |
0 |
|
2400 |
259546251 |
kaiboy rainboy |
A2 |
May 4, 2024, 6:16 p.m. |
OK |
GNU C11 |
TESTS |
27 |
62 |
4608000 |
|
2400 |
260576628 |
mohammadyamin |
A2 |
May 11, 2024, 6:58 p.m. |
OK |
GNU C11 |
TESTS |
27 |
77 |
4608000 |
|
2400 |
259996633 |
timiss |
A2 |
May 8, 2024, 12:19 p.m. |
OK |
GNU C11 |
TESTS |
27 |
78 |
4608000 |
|
2400 |
259695305 |
dzhi |
A2 |
May 6, 2024, 1:23 a.m. |
OK |
Java 21 |
TESTS |
27 |
281 |
1638400 |
|
2400 |
259671822 |
iamdeovrat |
A2 |
May 5, 2024, 6:46 p.m. |
OK |
Java 21 |
TESTS |
27 |
296 |
1024000 |
|
2400 |
259500545 |
mistb0rn |
A2 |
May 4, 2024, 11:29 a.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
78 |
0 |
|
2400 |
261086981 |
Repsaj21o |
A2 |
May 15, 2024, 5:23 p.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
93 |
0 |
|
2400 |
260500447 |
aha66 |
A2 |
May 11, 2024, 7:14 a.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
93 |
1433600 |
|
2400 |
259508664 |
edugong |
A2 |
May 4, 2024, 12:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
93 |
1433600 |
|
2400 |
261086157 |
Repsaj21o |
A2 |
May 15, 2024, 5:14 p.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
108 |
0 |
|
2400 |
259497310 |
chinerist |
A2 |
May 4, 2024, 11:03 a.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
108 |
3481600 |
|
2400 |
260869488 |
MdAbedin |
A2 |
May 14, 2024, 2:43 a.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
109 |
5734400 |
|
2400 |
260638724 |
Asuma_2014 |
A2 |
May 12, 2024, 9:09 a.m. |
OK |
PyPy 3-64 |
TESTS |
27 |
186 |
30003200 |
|
2400 |
260171072 |
mikkk |
A2 |
May 9, 2024, 7:28 p.m. |
OK |
Rust 2021 |
TESTS |
27 |
46 |
0 |
|
2400 |
259978847 |
BetterThanNobita |
A2 |
May 8, 2024, 9:47 a.m. |
OK |
Rust 2021 |
TESTS |
27 |
61 |
0 |
|
2400 |
remove filters
Back to search problems