Codeforces Round 1089 (Div. 2)

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
2210 Codeforces Round 1089 (Div. 2) FINISHED False 8100 1610723 March 29, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1906 ) D A Simple RBS Problem PROGRAMMING constructive algorithms strings trees

A bracket sequence is called regular if it is possible to obtain a correct arithmetic expression by inserting characters (+) and (1) into this sequence. For example, sequences (())() , () and (()(())) are regular, while )( , (() and (()))( are not. Let's call a regular bracket sequence RBS . You can perform the following operation on any RBS string (b) — Choose any two disjoint , non empty substrings(^{\text{∗}}) of (b) which are RBS and swap the two substrings. More formally, let (m) be the length of (b). You can perform the following operation on (b): Choose indices (1 \le l_1 \lt r_1 \lt l_2 \lt r_2 \le m) such that the substrings (b{l_1..r_1}) and (bl_2..r_2) are both RBS and swap these substrings. The string (b) becomes (b_1 \ldots b_{l_1-1} b_{l_2} b_{l_2+1}\ldots b_{r_2} b_{r_1+1}\ldots b_{l_2-1} b_{l_1} b_{l_1+1}\ldots b_{r_1}b_{r_2+1} \ldots b_m). You are given two strings (s) and (t) of length (n) ((n) is even ) such that both (s) and (t) are RBS. Determine whether you can transform (s) to (t) using the above operation any number of times. (^{\text{∗}})A string (a) is a substring of a string (b) if (a) can be obtained from (b) by the deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains an integer (n) ((4\leq n\leq 5\cdot 10^5), (n) is even ). The second line of each test case contains a string (s) of length (n) such that (s) is an RBS. The third line of each test case contains a string (t) of length (n) such that (t) is an RBS. It is guaranteed that the sum of (n) over all test cases does not exceed (5\cdot 10^5)

Tutorials

Codeforces Round 1089 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
368762628 Hemeda11 D March 29, 2026, 4:34 p.m. OK C# 13 TESTS 17 109 19660800

remove filters

Back to search problems