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'This is the hard version of this problem. The only difference is the limit of n - the length of the input string. In this version, 1 <= q n <= q 10^6 . Let 's define a correct bracket sequence and its depth as follow: For a (not necessarily correct) bracket sequence s , we define its depth as the maximum depth of any correct bracket sequence induced by removing some characters from s (possibly zero). For example: the bracket sequence s = "())(())" has depth 2 , because by removing the third character we obtain a correct bracket sequence "()(())" with depth 2 . Given a string a consists of only characters '( ', ') ' and '? '. Consider all (not necessarily correct) bracket sequences obtained by replacing all characters '? ' in a by either '( ' or ') '. Calculate the sum of all the depths of all these bracket sequences. As this number can be large, find it modulo 998244353 . Hacks in this problem can be done only if easy and hard versions of this problem was solved. The only line contains a non-empty string consist of only '( ', ') ' and '? '. The length of the string is at most 10^6 . Print the answer modulo 998244353 in a single line. In the first test case, we can obtain 4 bracket sequences by replacing all characters '? ' with either '( ' or ') ': So, the answer is 1 = 0 + 0 + 0 + 1 . In the second test case, we can obtain 4 bracket sequences by replacing all characters '? ' with either '( ' or ') ': So, the answer is 9 = 2 + 2 + 3 + 2 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
66464501 |
rainboy |
D2 |
Dec. 7, 2019, 4:02 p.m. |
OK |
GNU C11 |
TESTS |
62 |
295 |
9011200 |
|
3000 |
66373613 |
cjy2003 |
D2 |
Dec. 6, 2019, 12:46 a.m. |
OK |
GNU C++11 |
TESTS |
62 |
77 |
16896000 |
|
3000 |
66379581 |
AutumnKite |
D2 |
Dec. 6, 2019, 4:56 a.m. |
OK |
GNU C++11 |
TESTS |
62 |
78 |
8806400 |
|
3000 |
66658117 |
dqa2020 |
D2 |
Dec. 12, 2019, 2:03 a.m. |
OK |
GNU C++11 |
TESTS |
62 |
78 |
16896000 |
|
3000 |
66380960 |
lzoilxy |
D2 |
Dec. 6, 2019, 5:35 a.m. |
OK |
GNU C++11 |
TESTS |
62 |
78 |
16998400 |
|
3000 |
66930375 |
tyler178 |
D2 |
Dec. 15, 2019, 7:15 a.m. |
OK |
GNU C++11 |
TESTS |
62 |
78 |
16998400 |
|
3000 |
67056352 |
LJC00118 |
D2 |
Dec. 17, 2019, 7:02 a.m. |
OK |
GNU C++11 |
TESTS |
62 |
78 |
29081600 |
|
3000 |
66457444 |
bnaninaidu9949 |
D2 |
Dec. 7, 2019, 1:39 p.m. |
OK |
GNU C++11 |
TESTS |
62 |
93 |
8806400 |
|
3000 |
66374631 |
liqing |
D2 |
Dec. 6, 2019, 1:48 a.m. |
OK |
GNU C++11 |
TESTS |
62 |
93 |
16896000 |
|
3000 |
66378523 |
Isonan |
D2 |
Dec. 6, 2019, 4:27 a.m. |
OK |
GNU C++11 |
TESTS |
62 |
93 |
20889600 |
|
3000 |
69822528 |
cuizhuyefei |
D2 |
Jan. 30, 2020, 8:18 a.m. |
OK |
GNU C++11 |
TESTS |
62 |
93 |
25088000 |
|
3000 |
66535508 |
Aita_Venkata_Rishmitha |
D2 |
Dec. 9, 2019, 9:26 a.m. |
OK |
GNU C++14 |
TESTS |
62 |
93 |
9011200 |
|
3000 |
66434511 |
little_misfortune |
D2 |
Dec. 7, 2019, 5:28 a.m. |
OK |
GNU C++14 |
TESTS |
62 |
93 |
16998400 |
|
3000 |
66376168 |
jiangly |
D2 |
Dec. 6, 2019, 2:53 a.m. |
OK |
GNU C++14 |
TESTS |
62 |
93 |
17612800 |
|
3000 |
66380973 |
_Ash__ |
D2 |
Dec. 6, 2019, 5:35 a.m. |
OK |
GNU C++14 |
TESTS |
62 |
93 |
18124800 |
|
3000 |
66380561 |
Maripium |
D2 |
Dec. 6, 2019, 5:24 a.m. |
OK |
GNU C++14 |
TESTS |
62 |
93 |
29081600 |
|
3000 |
66379017 |
AuqaKyz |
D2 |
Dec. 6, 2019, 4:40 a.m. |
OK |
GNU C++14 |
TESTS |
62 |
93 |
33075200 |
|
3000 |
66454640 |
Origenes |
D2 |
Dec. 7, 2019, 12:43 p.m. |
OK |
GNU C++14 |
TESTS |
62 |
93 |
37171200 |
|
3000 |
66406890 |
wucstdio |
D2 |
Dec. 6, 2019, 1:58 p.m. |
OK |
GNU C++14 |
TESTS |
62 |
93 |
41062400 |
|
3000 |
66521832 |
Benq |
D2 |
Dec. 8, 2019, 11:39 p.m. |
OK |
GNU C++14 |
TESTS |
62 |
108 |
20787200 |
|
3000 |
66656938 |
Kananix |
D2 |
Dec. 12, 2019, 12:14 a.m. |
OK |
GNU C++14 |
TESTS |
62 |
108 |
29081600 |
|
3000 |
66482679 |
nickluo |
D2 |
Dec. 8, 2019, 4 a.m. |
OK |
GNU C++17 |
TESTS |
62 |
78 |
21606400 |
|
3000 |
66466709 |
Roundgod |
D2 |
Dec. 7, 2019, 4:46 p.m. |
OK |
GNU C++17 |
TESTS |
62 |
78 |
29081600 |
|
3000 |
66386897 |
Shayan.P |
D2 |
Dec. 6, 2019, 7:49 a.m. |
OK |
GNU C++17 |
TESTS |
62 |
92 |
18124800 |
|
3000 |
66668736 |
Lawali |
D2 |
Dec. 12, 2019, 8:20 a.m. |
OK |
GNU C++17 |
TESTS |
62 |
92 |
30208000 |
|
3000 |
66524042 |
Twishkle.Aevdark |
D2 |
Dec. 9, 2019, 2:50 a.m. |
OK |
GNU C++17 |
TESTS |
62 |
93 |
9011200 |
|
3000 |
66506644 |
abc473848880 |
D2 |
Dec. 8, 2019, 2:41 p.m. |
OK |
GNU C++17 |
TESTS |
62 |
93 |
16998400 |
|
3000 |
66345089 |
jiangly |
D2 |
Dec. 5, 2019, 3:46 p.m. |
OK |
GNU C++17 |
TESTS |
62 |
93 |
17612800 |
|
3000 |
69495756 |
cuiaoxiang |
D2 |
Jan. 25, 2020, 3:48 a.m. |
OK |
GNU C++17 |
TESTS |
62 |
93 |
21094400 |
|
3000 |
66373431 |
xgcxgc |
D2 |
Dec. 6, 2019, 12:35 a.m. |
OK |
GNU C++17 |
TESTS |
62 |
93 |
21094400 |
|
3000 |
66580743 |
JHSN |
D2 |
Dec. 10, 2019, 9:15 a.m. |
OK |
GNU C++17 |
TESTS |
62 |
93 |
25088000 |
|
3000 |
66464500 |
Dukkha |
D2 |
Dec. 7, 2019, 4:02 p.m. |
OK |
Java 11 |
TESTS |
62 |
592 |
8089600 |
|
3000 |
66615469 |
uwi |
D2 |
Dec. 11, 2019, 3:26 a.m. |
OK |
Java 8 |
TESTS |
62 |
295 |
58368000 |
|
3000 |
remove filters
Back to search problems