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.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
---|---|---|---|---|---|---|
1750 | CodeTON Round 3 (Div. 1 + Div. 2, Rated, Prizes!) | FINISHED | False | 9000 | 69521063 | Nov. 6, 2022, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 1478 ) | E | Bracket Cost | PROGRAMMING | binary search data structures divide and conquer dp greedy strings |
B'Daemon Targaryen decided to stop looking like a Metin2 character. He turned himself into the most beautiful thing, a bracket sequence. For a bracket sequence, we can do two kind of operations: We define the cost of a bracket sequence as the minimum number of such operations to make it balanced ^ ddagger . Given a bracket sequence s of length n , find the sum of costs across all its frac{n(n+1)}{2} non-empty substrings. Note that for each substring we calculate the cost independently. ^ dagger A string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end. ^ ddagger A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters + and 1 . For example, sequences "(())()", "()", and "(()(()))" are balanced, while ")(", "(()", and "(()))(" are not. Each test consists of multiple test cases. The first line contains a single integer t ( 1 <= q t <= q 10^5 ) -- the number of test cases. The description of 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 bracket sequence. The second line of each test case contains a string s , consisting only of characters '( ' and ') ', of length n -- the bracket sequence. It is guaranteed that sum of n across all test cases does not exceed 2 cdot 10^5 . For each test case, print a single integer -- the sum of costs of all substrings of s . In the first test case, there is the only substring ")". Its cost is 1 because we can insert '( ' to the beginning of this substring and get a string "()", that is a balanced string. In the second test case, the cost of each substring of length one is 1 . The cost of a substring ")(" is 1 becaus'... |
CodeTON Round 3 (Div. 1 + Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
179628144 | mban259 | E | Nov. 6, 2022, 4:47 p.m. | OK | C# 10 | TESTS | 29 | 155 | 40448000 | ||
179717478 | rainboy | E | Nov. 6, 2022, 5:44 p.m. | OK | GNU C11 | TESTS | 29 | 421 | 5017600 | ||
179626019 | hhhgjyismine | E | Nov. 6, 2022, 4:39 p.m. | OK | GNU C++14 | TESTS | 29 | 31 | 41164800 | ||
179619754 | cyh_toby | E | Nov. 6, 2022, 4:14 p.m. | OK | GNU C++14 | TESTS | 29 | 46 | 2662400 | ||
179832024 | czyer | E | Nov. 7, 2022, 12:47 a.m. | OK | GNU C++14 | TESTS | 29 | 46 | 4198400 | ||
179840233 | QQH | E | Nov. 7, 2022, 2:24 a.m. | OK | GNU C++14 | TESTS | 29 | 46 | 4198400 | ||
179632667 | Deep_Kevin | E | Nov. 6, 2022, 4:55 p.m. | OK | GNU C++14 | TESTS | 29 | 46 | 5017600 | ||
179831324 | Tyyyyyy | E | Nov. 7, 2022, 12:29 a.m. | OK | GNU C++14 | TESTS | 29 | 46 | 10547200 | ||
179843038 | hotpotcondiment | E | Nov. 7, 2022, 3:14 a.m. | OK | GNU C++14 | TESTS | 29 | 46 | 25088000 | ||
179841403 | zlsim | E | Nov. 7, 2022, 2:44 a.m. | OK | GNU C++14 | TESTS | 29 | 46 | 41062400 | ||
179631224 | cryozwq | E | Nov. 6, 2022, 4:51 p.m. | OK | GNU C++14 | TESTS | 29 | 46 | 66150400 | ||
179627405 | Goshkata | E | Nov. 6, 2022, 4:43 p.m. | OK | GNU C++14 | TESTS | 29 | 61 | 7270400 | ||
179830355 | acwing_meow | E | Nov. 7, 2022, midnight | OK | GNU C++17 | TESTS | 29 | 31 | 8192000 | ||
179625530 | Unlimited_zero | E | Nov. 6, 2022, 4:37 p.m. | OK | GNU C++17 | TESTS | 29 | 46 | 4198400 | ||
179625892 | gabrielwu | E | Nov. 6, 2022, 4:38 p.m. | OK | GNU C++17 | TESTS | 29 | 46 | 4300800 | ||
179631141 | xxxxx250 | E | Nov. 6, 2022, 4:50 p.m. | OK | GNU C++17 | TESTS | 29 | 46 | 6553600 | ||
179614200 | applese | E | Nov. 6, 2022, 3:52 p.m. | OK | GNU C++17 | TESTS | 29 | 46 | 6656000 | ||
179619377 | GyojunYoun | E | Nov. 6, 2022, 4:13 p.m. | OK | GNU C++17 | TESTS | 29 | 46 | 7168000 | ||
179616501 | zhangshaojia | E | Nov. 6, 2022, 4 p.m. | OK | GNU C++17 | TESTS | 29 | 46 | 9625600 | ||
179837244 | lx_tyin | E | Nov. 7, 2022, 1:18 a.m. | OK | GNU C++17 | TESTS | 29 | 46 | 13107200 | ||
179836904 | tokusakurai | E | Nov. 7, 2022, 1:09 a.m. | OK | GNU C++17 | TESTS | 29 | 61 | 3788800 | ||
179841105 | ability_66 | E | Nov. 7, 2022, 2:39 a.m. | OK | GNU C++17 | TESTS | 29 | 61 | 8499200 | ||
179685291 | Hackenbush | E | Nov. 6, 2022, 5:30 p.m. | OK | GNU C++17 (64) | TESTS | 29 | 31 | 4505600 | ||
179627446 | zer0brain | E | Nov. 6, 2022, 4:43 p.m. | OK | GNU C++17 (64) | TESTS | 29 | 46 | 512000 | ||
179829327 | 5ab | E | Nov. 6, 2022, 11:21 p.m. | OK | GNU C++17 (64) | TESTS | 29 | 46 | 4300800 | ||
179625229 | PikachuCloneAccount | E | Nov. 6, 2022, 4:36 p.m. | OK | GNU C++17 (64) | TESTS | 29 | 46 | 5324800 | ||
179627207 | jack112739 | E | Nov. 6, 2022, 4:42 p.m. | OK | GNU C++17 (64) | TESTS | 29 | 46 | 8294400 | ||
179624710 | keywet06 | E | Nov. 6, 2022, 4:34 p.m. | OK | GNU C++17 (64) | TESTS | 29 | 46 | 11468800 | ||
179684954 | alexchist | E | Nov. 6, 2022, 5:27 p.m. | OK | GNU C++17 (64) | TESTS | 29 | 46 | 19251200 | ||
179633189 | Kazumin | E | Nov. 6, 2022, 4:56 p.m. | OK | GNU C++17 (64) | TESTS | 29 | 46 | 20684800 | ||
179729876 | Freedom__King | E | Nov. 6, 2022, 5:51 p.m. | OK | GNU C++17 (64) | TESTS | 29 | 46 | 72499200 | ||
179620749 | Kude | E | Nov. 6, 2022, 4:18 p.m. | OK | GNU C++17 (64) | TESTS | 29 | 61 | 3788800 | ||
179628272 | Sorting | E | Nov. 6, 2022, 4:48 p.m. | OK | GNU C++20 (64) | TESTS | 29 | 30 | 7782400 | ||
179816275 | leafeon | E | Nov. 6, 2022, 7:14 p.m. | OK | GNU C++20 (64) | TESTS | 29 | 31 | 1331200 | ||
179618280 | ub33 | E | Nov. 6, 2022, 4:08 p.m. | OK | GNU C++20 (64) | TESTS | 29 | 31 | 2150400 | ||
179900468 | becaido | E | Nov. 7, 2022, 5:50 a.m. | OK | GNU C++20 (64) | TESTS | 29 | 31 | 2150400 | ||
179823477 | maxplus | E | Nov. 6, 2022, 9:02 p.m. | OK | GNU C++20 (64) | TESTS | 29 | 31 | 3686400 | ||
179875131 | S_Samchenko | E | Nov. 7, 2022, 5:20 a.m. | OK | GNU C++20 (64) | TESTS | 29 | 31 | 5324800 | ||
179837722 | 765 | E | Nov. 7, 2022, 1:29 a.m. | OK | GNU C++20 (64) | TESTS | 29 | 31 | 5324800 | ||
179632080 | Macesuted-Moe | E | Nov. 6, 2022, 4:52 p.m. | OK | GNU C++20 (64) | TESTS | 29 | 31 | 6144000 | ||
179614899 | rgnerdplayer | E | Nov. 6, 2022, 3:54 p.m. | OK | GNU C++20 (64) | TESTS | 29 | 31 | 6963200 | ||
179616496 | HollwoQ_Pelw | E | Nov. 6, 2022, 4 p.m. | OK | GNU C++20 (64) | TESTS | 29 | 31 | 10137600 | ||
179639784 | yehara | E | Nov. 6, 2022, 4:59 p.m. | OK | Java 11 | TESTS | 29 | 342 | 0 | ||
179788921 | Dukkha | E | Nov. 6, 2022, 6:31 p.m. | OK | Java 17 | TESTS | 29 | 436 | 7475200 | ||
179768178 | huangxw | E | Nov. 6, 2022, 6:19 p.m. | OK | PyPy 3-64 | TESTS | 29 | 218 | 13312000 | ||
179774195 | huangxw | E | Nov. 6, 2022, 6:20 p.m. | OK | PyPy 3-64 | TESTS | 29 | 249 | 13312000 | ||
179763552 | eepsilon | E | Nov. 6, 2022, 6:18 p.m. | OK | PyPy 3-64 | TESTS | 29 | 295 | 11980800 | ||
179684054 | shobonvip | E | Nov. 6, 2022, 5:22 p.m. | OK | PyPy 3-64 | TESTS | 29 | 327 | 18534400 | ||
179723204 | Maruzensky | E | Nov. 6, 2022, 5:45 p.m. | OK | PyPy 3-64 | TESTS | 29 | 732 | 35225600 | ||
179621484 | conqueror_of_tourist | E | Nov. 6, 2022, 4:22 p.m. | OK | PyPy 3-64 | TESTS | 29 | 1075 | 25907200 | ||
179684124 | rikein12 | E | Nov. 6, 2022, 5:22 p.m. | OK | PyPy 3-64 | TESTS | 29 | 1497 | 31334400 |
Back to search problems