Codeforces Round 794 (Div. 1)

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
1685 Codeforces Round 794 (Div. 1) FINISHED False 8100 83766263 May 25, 2022, 5:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1109 ) C Bring Balance PROGRAMMING constructive algorithms greedy 2600

B"Alina has a bracket sequence s of length 2n , consisting of n opening brackets '(' and n closing brackets ')'. As she likes balance, she wants to turn this bracket sequence into a balanced bracket sequence. In one operation, she can reverse any substring of s . What's the smallest number of operations that she needs to turn s into a balanced bracket sequence? It can be shown that it's always possible in at most n operations. As a reminder, 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. The first line of the input contains a single integer t ( 1 <= t <= 2 cdot 10^4 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 10^5 ). The second line of each test case contains a string s of length 2n , consisting of n opening and n closing brackets. The sum of n over all test cases doesn't exceed 2 cdot 10^5 . For each test case, in the first line output a single integer k (0 <= k <= n) -- the smallest number of operations required. The i -th of the next k lines should contain two integers l_i, r_i ( 1 <= l_i <= r_i <= 2n ), indicating that in the i -th operation, Alina will reverse the substring s_ls_{l+1} ldots s_{r-1}s_r . Here the numeration starts from 1 . If there are multiple sequences of operations with the smallest length which transform the sequence into a balanced one, you can output any of them. In the first test case, the string is already balanced. In the second test case, the string will be transformed as follows: ())((()))( to ()()(()))( to ()()(())(), where the last string is balanced. In the third test case, the string w"...

Tutorials

103198

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
158444104 hos.lyric C May 25, 2022, 6:24 p.m. OK D TESTS 26 46 6144000 2600
158465773 Gassa C May 25, 2022, 7:41 p.m. OK D TESTS 26 78 6144000 2600
158446351 dlalswp25 C May 25, 2022, 6:29 p.m. OK GNU C++14 TESTS 26 15 204800 2600
158496776 hotpotcondiment C May 26, 2022, 6:26 a.m. OK GNU C++14 TESTS 26 15 1024000 2600
158480726 L7-56 C May 26, 2022, 1:24 a.m. OK GNU C++14 TESTS 26 15 1024000 2600
158480583 lin7xu C May 26, 2022, 1:19 a.m. OK GNU C++14 TESTS 26 15 1331200 2600
158482973 WHC-MIK-7521X C May 26, 2022, 2:27 a.m. OK GNU C++14 TESTS 26 30 1024000 2600
158481598 antguz C May 26, 2022, 1:52 a.m. OK GNU C++14 TESTS 26 30 1024000 2600
158473988 Potassium C May 25, 2022, 9:29 p.m. OK GNU C++14 TESTS 26 30 1638400 2600
158508504 themoon C May 26, 2022, 8:58 a.m. OK GNU C++14 TESTS 26 31 819200 2600
158579578 suyiheng C May 27, 2022, 4:39 a.m. OK GNU C++14 TESTS 26 31 1024000 2600
158486081 LZDQ C May 26, 2022, 3:34 a.m. OK GNU C++14 TESTS 26 31 1024000 2600
158463552 Bohun C May 25, 2022, 7:30 p.m. OK GNU C++17 TESTS 26 15 1024000 2600
158505153 ace-in-the-hole C May 26, 2022, 8:14 a.m. OK GNU C++17 TESTS 26 15 1331200 2600
158534728 anodiebird C May 26, 2022, 1:57 p.m. OK GNU C++17 TESTS 26 30 204800 2600
158446162 LJC00118 C May 25, 2022, 6:29 p.m. OK GNU C++17 TESTS 26 30 204800 2600
158559593 himadri765 C May 26, 2022, 6:48 p.m. OK GNU C++17 TESTS 26 30 1331200 2600
158453229 TeaPot C May 25, 2022, 6:50 p.m. OK GNU C++17 TESTS 26 30 1331200 2600
158509758 Lemur95 C May 26, 2022, 9:15 a.m. OK GNU C++17 TESTS 26 30 2969600 2600
158459166 AliShahali1382 C May 25, 2022, 7:11 p.m. OK GNU C++17 TESTS 26 30 2969600 2600
158466254 Wailydest C May 25, 2022, 7:44 p.m. OK GNU C++17 TESTS 26 31 204800 2600
158509283 Fairy_Tale C May 26, 2022, 9:09 a.m. OK GNU C++17 TESTS 26 31 512000 2600
158462347 JaroslavUrban C May 25, 2022, 7:25 p.m. OK GNU C++17 (64) TESTS 26 15 1331200 2600
158512017 anonymous_777 C May 26, 2022, 9:43 a.m. OK GNU C++17 (64) TESTS 26 15 1536000 2600
158470736 Merlininice C May 25, 2022, 8:30 p.m. OK GNU C++17 (64) TESTS 26 15 6553600 2600
158438857 potato167 C May 25, 2022, 6:12 p.m. OK GNU C++17 (64) TESTS 26 30 512000 2600
158562130 BERNARB.01 C May 26, 2022, 7:28 p.m. OK GNU C++17 (64) TESTS 26 30 1331200 2600
158530522 codr0 C May 26, 2022, 1:13 p.m. OK GNU C++17 (64) TESTS 26 30 1331200 2600
158450556 kotatsugame C May 25, 2022, 6:41 p.m. OK GNU C++17 (64) TESTS 26 30 1536000 2600
158448568 Kirill_Kudr22 C May 25, 2022, 6:35 p.m. OK GNU C++17 (64) TESTS 26 30 2560000 2600
158438284 Petr C May 25, 2022, 6:11 p.m. OK GNU C++17 (64) TESTS 26 31 512000 2600
158464617 creep C May 25, 2022, 7:36 p.m. OK GNU C++17 (64) TESTS 26 31 1331200 2600
158447393 dreamoon_love_AA C May 25, 2022, 6:32 p.m. OK GNU C++20 (64) TESTS 26 15 512000 2600
158468957 Egor.Lifar C May 25, 2022, 8:14 p.m. OK GNU C++20 (64) TESTS 26 15 819200 2600
158447760 Ormlis C May 25, 2022, 6:33 p.m. OK GNU C++20 (64) TESTS 26 15 819200 2600
158461124 dsgrekova2 C May 25, 2022, 7:20 p.m. OK GNU C++20 (64) TESTS 26 15 1126400 2600
158510794 Estinka C May 26, 2022, 9:28 a.m. OK GNU C++20 (64) TESTS 26 15 1638400 2600
158541255 lis05 C May 26, 2022, 2:59 p.m. OK GNU C++20 (64) TESTS 26 15 2048000 2600
158562093 arbuzick C May 26, 2022, 7:28 p.m. OK GNU C++20 (64) TESTS 26 15 2150400 2600
158552329 Sorting C May 26, 2022, 5:11 p.m. OK GNU C++20 (64) TESTS 26 15 2150400 2600
158536551 tdsb C May 26, 2022, 2:17 p.m. OK GNU C++20 (64) TESTS 26 15 2150400 2600
158452983 risujiroh C May 25, 2022, 6:49 p.m. OK GNU C++20 (64) TESTS 26 15 2150400 2600
158467310 SecondThread C May 25, 2022, 7:48 p.m. OK Java 8 TESTS 26 155 38297600 2600
158471784 Hakiobo C May 25, 2022, 8:44 p.m. OK Kotlin 1.4 TESTS 26 155 1228800 2600
158534747 ruimina C May 26, 2022, 1:57 p.m. OK PyPy 3 TESTS 26 233 11264000 2600
158443576 conqueror_of_tourist C May 25, 2022, 6:23 p.m. OK PyPy 3-64 TESTS 26 233 14131200 2600
158525394 asdsasd C May 26, 2022, 12:19 p.m. OK PyPy 3-64 TESTS 26 234 13414400 2600

remove filters

Back to search problems