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'Owl Pacino has always been into trees -- unweighted rooted trees in particular. He loves determining the diameter of every tree he sees -- that is, the maximum length of any simple path in the tree. Owl Pacino 's owl friends decided to present him the Tree Generator xe2 x84 xa2 -- a powerful machine creating rooted trees from their descriptions. An n -vertex rooted tree can be described by a bracket sequence of length 2(n - 1) in the following way: find any walk starting and finishing in the root that traverses each edge exactly twice -- once down the tree, and later up the tree. Then follow the path and write down "(" (an opening parenthesis) if an edge is followed down the tree, and ")" (a closing parenthesis) otherwise. The following figure shows sample rooted trees and their descriptions: Owl wrote down the description of an n -vertex rooted tree. Then, he rewrote the description q times. However, each time he wrote a new description, he picked two different characters in the description he wrote the last time, swapped them and wrote down the resulting string. He always made sure that each written string was the description of a rooted tree. Pacino then used Tree Generator xe2 x84 xa2 for each description he wrote down. What is the diameter of each constructed tree? The first line of the input contains two integers n, q ( 3 <= n <= 100 ,000 , 1 <= q <= 100 ,000 ) -- the number of vertices in the tree and the number of changes to the tree description. The following line contains a description of the initial tree -- a string of length 2(n-1) consisting of opening and closing parentheses. Each of the following q lines describes a single change to the description and contains two space-separated integers a_i, b_i ( 2 <= q a_i, b_i <= q 2n-3 ) which identify the indices of two brackets to be swapped. You can assume that the description will change after each query, and that after each change a tree can be co'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
53528547 |
rainboy |
C |
April 29, 2019, 6:08 p.m. |
OK |
GNU C11 |
TESTS |
31 |
670 |
34611200 |
|
2900 |
53525523 |
1919810 |
C |
April 29, 2019, 4:23 p.m. |
OK |
GNU C++11 |
TESTS |
31 |
124 |
15769600 |
|
2900 |
53593759 |
xor5283 |
C |
May 1, 2019, 2:37 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
124 |
29081600 |
|
2900 |
54097445 |
yzh666 |
C |
May 14, 2019, 1:51 p.m. |
OK |
GNU C++11 |
TESTS |
31 |
124 |
29081600 |
|
2900 |
53601706 |
xor5283 |
C |
May 1, 2019, 8:04 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
124 |
29081600 |
|
2900 |
55610326 |
ReaLNero1 |
C |
June 16, 2019, 5:16 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
124 |
29900800 |
|
2900 |
67948550 |
20050901 |
C |
Dec. 30, 2019, 6:37 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
124 |
145305600 |
|
2900 |
56513585 |
luogu_bot1 |
C |
July 4, 2019, 11:40 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
139 |
19456000 |
|
2900 |
54240435 |
LJC00118 |
C |
May 16, 2019, 12:43 p.m. |
OK |
GNU C++11 |
TESTS |
31 |
139 |
20275200 |
|
2900 |
53592868 |
Dilute |
C |
May 1, 2019, 1:51 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
139 |
29900800 |
|
2900 |
57482617 |
xielinhan |
C |
July 22, 2019, 3:16 a.m. |
OK |
GNU C++11 |
TESTS |
31 |
140 |
13004800 |
|
2900 |
56690948 |
CSXiang |
C |
July 8, 2019, 3:45 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
156 |
261529600 |
|
2900 |
57815326 |
risujiroh |
C |
July 26, 2019, 7:21 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
171 |
11776000 |
|
2900 |
53583138 |
davidberard |
C |
April 30, 2019, 4:46 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
171 |
12800000 |
|
2900 |
54022156 |
yzyyylx |
C |
May 12, 2019, 10:24 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
171 |
13004800 |
|
2900 |
54344953 |
jo_on |
C |
May 18, 2019, noon |
OK |
GNU C++14 |
TESTS |
31 |
171 |
13107200 |
|
2900 |
66251556 |
latte0119 |
C |
Dec. 4, 2019, 2:25 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
171 |
19353600 |
|
2900 |
66251763 |
latte0119 |
C |
Dec. 4, 2019, 2:36 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
171 |
19353600 |
|
2900 |
54558979 |
pkgunboat |
C |
May 24, 2019, 1:02 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
171 |
19456000 |
|
2900 |
64341404 |
tzxydby |
C |
Nov. 6, 2019, 3:01 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
171 |
19456000 |
|
2900 |
53586233 |
_no0B |
C |
April 30, 2019, 6:42 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
171 |
20275200 |
|
2900 |
53726574 |
KillerX |
C |
May 4, 2019, 4:49 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
124 |
12902400 |
|
2900 |
53657517 |
CMXRYNP |
C |
May 2, 2019, 5:48 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
124 |
30208000 |
|
2900 |
53538996 |
MrDindows |
C |
April 30, 2019, 5:13 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
139 |
17510400 |
|
2900 |
53587037 |
lmiskiew |
C |
April 30, 2019, 7:15 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
155 |
15257600 |
|
2900 |
60941280 |
dupazbitastorazy |
C |
Sept. 20, 2019, 5:10 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
156 |
14540800 |
|
2900 |
53539131 |
MrDindows |
C |
April 30, 2019, 5:19 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
156 |
17510400 |
|
2900 |
53694503 |
Huah |
C |
May 3, 2019, 6:57 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
156 |
19456000 |
|
2900 |
53689174 |
Huah |
C |
May 3, 2019, 3:25 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
171 |
13107200 |
|
2900 |
53538993 |
MrDindows |
C |
April 30, 2019, 5:13 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
171 |
17510400 |
|
2900 |
53689453 |
Huah |
C |
May 3, 2019, 3:37 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
171 |
19456000 |
|
2900 |
53520960 |
Petr |
C |
April 29, 2019, 3:49 p.m. |
OK |
Java 8 |
TESTS |
31 |
389 |
32256000 |
|
2900 |
53826168 |
Jeel_Vaishnav |
C |
May 6, 2019, 4:15 p.m. |
OK |
Java 8 |
TESTS |
31 |
592 |
33894400 |
|
2900 |
61889176 |
cornfields |
C |
Oct. 5, 2019, 5:03 a.m. |
OK |
Java 8 |
TESTS |
31 |
655 |
37171200 |
|
2900 |
53530626 |
Dukkha |
C |
April 29, 2019, 7:57 p.m. |
OK |
Java 8 |
TESTS |
31 |
1216 |
118988800 |
|
2900 |
53525803 |
uwi |
C |
April 29, 2019, 4:26 p.m. |
OK |
Java 8 |
TESTS |
31 |
1466 |
29184000 |
|
2900 |
53531472 |
EbTech |
C |
April 29, 2019, 8:42 p.m. |
OK |
Rust |
TESTS |
31 |
1419 |
17920000 |
|
2900 |
remove filters
Back to search problems