CSES - Aalto Competitive Programming 2024 - wk9 - Wed - Results
Submission details
Task:Bracket sequence
Sender:aalto2024j_005
Submission time:2024-11-06 16:23:53 +0200
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.04 sdetails
#3ACCEPTED0.04 sdetails
#4ACCEPTED0.04 sdetails
#50.04 sdetails
#6ACCEPTED0.04 sdetails
#7ACCEPTED0.04 sdetails
#8ACCEPTED0.04 sdetails
#90.04 sdetails
#10ACCEPTED0.04 sdetails
#11ACCEPTED0.04 sdetails
#120.04 sdetails
#13ACCEPTED0.04 sdetails
#14ACCEPTED0.04 sdetails
#15ACCEPTED0.04 sdetails
#16ACCEPTED0.04 sdetails
#170.04 sdetails
#18ACCEPTED0.04 sdetails
#19ACCEPTED0.04 sdetails
#20ACCEPTED0.04 sdetails
#21ACCEPTED0.04 sdetails
#220.04 sdetails
#23ACCEPTED0.04 sdetails
#24ACCEPTED0.04 sdetails
#25ACCEPTED0.04 sdetails
#260.04 sdetails
#27ACCEPTED0.04 sdetails
#280.04 sdetails
#29ACCEPTED0.04 sdetails
#30ACCEPTED0.04 sdetails
#31ACCEPTED0.04 sdetails
#320.04 sdetails
#330.04 sdetails
#34ACCEPTED0.04 sdetails
#35ACCEPTED0.04 sdetails
#360.04 sdetails
#37ACCEPTED0.04 sdetails
#38ACCEPTED0.04 sdetails
#39ACCEPTED0.04 sdetails
#40ACCEPTED0.04 sdetails
#41ACCEPTED0.04 sdetails
#420.04 sdetails
#430.04 sdetails
#44ACCEPTED0.04 sdetails
#45ACCEPTED0.04 sdetails
#46ACCEPTED0.04 sdetails
#47ACCEPTED0.04 sdetails
#480.04 sdetails
#49ACCEPTED0.04 sdetails
#50ACCEPTED0.04 sdetails
#510.04 sdetails
#520.04 sdetails
#53ACCEPTED0.04 sdetails
#54ACCEPTED0.04 sdetails
#55ACCEPTED0.04 sdetails
#56ACCEPTED0.33 sdetails
#570.21 sdetails
#58ACCEPTED0.39 sdetails
#59ACCEPTED0.19 sdetails
#60ACCEPTED0.04 sdetails
#61ACCEPTED0.15 sdetails
#620.41 sdetails
#63ACCEPTED0.08 sdetails
#64ACCEPTED0.41 sdetails
#650.40 sdetails

Code

s = input()
res = ''
cur_res = ''
cur_open = 0
for i in s:
    cur_res += i
    if i == '(':
        cur_open += 1
    else:
        cur_open -= 1
    if cur_open == 0 and len(res) < len(cur_res):
        res = cur_res
    if cur_open < 0:
        cur_open = 0
        cur_res = ''
if len(res) > 0:
    print(res)
else:
    print('-1')

Test details

Test 1

Verdict: ACCEPTED

input
(

correct output
-1

user output
-1

Test 2

Verdict: ACCEPTED

input
))

correct output
-1

user output
-1

Test 3

Verdict: ACCEPTED

input
((

correct output
-1

user output
-1

Test 4

Verdict: ACCEPTED

input
()

correct output
()

user output
()

Test 5

Verdict:

input
(()

correct output
()

user output
-1

Test 6

Verdict: ACCEPTED

input
()()

correct output
()()

user output
()()

Test 7

Verdict: ACCEPTED

input
))))

correct output
-1

user output
-1

Test 8

Verdict: ACCEPTED

input
())(

correct output
()

user output
()

Test 9

Verdict:

input
(()(

correct output
()

user output
-1

Test 10

Verdict: ACCEPTED

input
)))))

correct output
-1

user output
-1

Test 11

Verdict: ACCEPTED

input
())(()

correct output
()

user output
()

Test 12

Verdict:

input
))(()(

correct output
()

user output
-1

Test 13

Verdict: ACCEPTED

input
()(())

correct output
()(())

user output
()(())

Test 14

Verdict: ACCEPTED

input
()(())

correct output
()(())

user output
()(())

Test 15

Verdict: ACCEPTED

input
()((((

correct output
()

user output
()

Test 16

Verdict: ACCEPTED

input
(())(())((

correct output
(())(())

user output
(())(())

Test 17

Verdict:

input
)))((()(((

correct output
()

user output
-1

Test 18

Verdict: ACCEPTED

input
(()))(((((

correct output
(())

user output
(())

Test 19

Verdict: ACCEPTED

input
())(()())(

correct output
(()())

user output
(()())

Test 20

Verdict: ACCEPTED

input
))))))))))

correct output
-1

user output
-1

Test 21

Verdict: ACCEPTED

input
())(())(()

correct output
(())

user output
(())

Test 22

Verdict:

input
)((())(()(

correct output
(())

user output
-1

Test 23

Verdict: ACCEPTED

input
()(())()()

correct output
()(())()()

user output
()(())()()

Test 24

Verdict: ACCEPTED

input
()(())((()

correct output
()(())

user output
()(())

Test 25

Verdict: ACCEPTED

input
()((((((((

correct output
()

user output
()

Test 26

Verdict:

input
((((((())))))))(((((((((()))))...

correct output
(((((())))))(((((((((()))))(((...

user output
((((((()))))))

Test 27

Verdict: ACCEPTED

input
)))((()((((((()()))(())(()(())...

correct output
((()((((((()()))(())(()(()))((...

user output
((()((((((()()))(())(()(()))((...

Test 28

Verdict:

input
(()))((((((())(((()))))(())())...

correct output
(((())((()()(((((())()))())))(...

user output
(())

Test 29

Verdict: ACCEPTED

input
())))))))(((((((((())))(()))))...

correct output
(((((((((())))(())))))((((((()...

user output
(((((((((())))(())))))((((((()...

Test 30

Verdict: ACCEPTED

input
))))))))))))))))))))))))))))))...

correct output
-1

user output
-1

Test 31

Verdict: ACCEPTED

input
())(())(()()()(()()()))((())((...

correct output
(())(()()()(()()()))((())(((((...

user output
(())(()()()(()()()))((())(((((...

Test 32

Verdict:

input
(((((((((()))))))))((((((((())...

correct output
((((((((()))))))))

user output
-1

Test 33

Verdict:

input
()(())()()()(((((())))(((()())...

correct output
((((())))(((()()))((())(())())...

user output
()(())()()()

Test 34

Verdict: ACCEPTED

input
()(())((()))(((())))((((()))))...

correct output
()(())((()))(((())))((((()))))...

user output
()(())((()))(((())))((((()))))...

Test 35

Verdict: ACCEPTED

input
()(((((((()(((((((((()())())))...

correct output
()(((((((()(((((((((()())())))...

user output
()(((((((()(((((((((()())())))...

Test 36

Verdict:

input
((((((((((((())))))))))))))))(...

correct output
((((((((((((((()))))))))))))((...

user output
((((((((((((()))))))))))))

Test 37

Verdict: ACCEPTED

input
)))((()((((((()()))(())(()(())...

correct output
((()((((()(()((()(())()((()())...

user output
((()((((()(()((()(())()((()())...

Test 38

Verdict: ACCEPTED

input
(()))((((((())(((()))))(())())...

correct output
((((((())(((()))))(())())())((...

user output
((((((())(((()))))(())())())((...

Test 39

Verdict: ACCEPTED

input
(()))))))))))))))(((((((((((((...

correct output
(((((((((((((((((()))))))((())...

user output
(((((((((((((((((()))))))((())...

Test 40

Verdict: ACCEPTED

input
))))))))))))))))))))))))))))))...

correct output
-1

user output
-1

Test 41

Verdict: ACCEPTED

input
())(())(()()()(()()()))((())((...

correct output
(())(()()()(()()()))((())(((((...

user output
(())(()()()(()()()))((())(((((...

Test 42

Verdict:

input
))))(((((((((((((())))))))))))...

correct output
((((((((((((()))))))))))))

user output
-1

Test 43

Verdict:

input
()(())()()()(((((())))(((()())...

correct output
()()(((()())(()(((()(()(()(()(...

user output
()(())()()()

Test 44

Verdict: ACCEPTED

input
()(())((()))(((())))((((()))))...

correct output
()(())((()))(((())))((((()))))...

user output
()(())((()))(((())))((((()))))...

Test 45

Verdict: ACCEPTED

input
()(((((((()(((((((((()())())))...

correct output
()(((((((()(((((((((()())())))...

user output
()(((((((()(((((((((()())())))...

Test 46

Verdict: ACCEPTED

input
((((((((((((((((((((((((((((((...

correct output
((((((((((((((((((((((((((((((...

user output
((((((((((((((((((((((((((((((...

Test 47

Verdict: ACCEPTED

input
)))((()((((((()()))(())(()(())...

correct output
(((())()((()))()())((((((()(()...

user output
(((())()((()))()())((((((()(()...

Test 48

Verdict:

input
(()))((((((())(((()))))(())())...

correct output
((()))(()()((()()((((()()()(()...

user output
((((((())(((()))))(())())())((...

Test 49

Verdict: ACCEPTED

input
(((((((())))))))))))))))))))))...

correct output
((((((((((((((((((((((((((((((...

user output
((((((((((((((((((((((((((((((...

Test 50

Verdict: ACCEPTED

input
))))))))))))))))))))))))))))))...

correct output
-1

user output
-1

Test 51

Verdict:

input
())(())(()()()(()()()))((())((...

correct output
(((()((((((()(((((()(((()(((()...

user output
((()()))(((()(((((()()()))()()...

Test 52

Verdict:

input
(((((((())))))))))))))))))))))...

correct output
((((((((((((((((((((((((((((((...

user output
(((((((())))))))

Test 53

Verdict: ACCEPTED

input
()(())()()()(((((())))(((()())...

correct output
()(())()()()(((((())))(((()())...

user output
()(())()()()(((((())))(((()())...

Test 54

Verdict: ACCEPTED

input
()(())((()))(((())))((((()))))...

correct output
()(())((()))(((())))((((()))))...

user output
()(())((()))(((())))((((()))))...

Test 55

Verdict: ACCEPTED

input
()(((((((()(((((((((()())())))...

correct output
(((())((())(())(((()(()()(()()...

user output
(((())((())(())(((()(()()(()()...

Test 56

Verdict: ACCEPTED

input
((((((((((((((((((((((((((((((...

correct output
((((((((((((((((((((((((((((((...

user output
((((((((((((((((((((((((((((((...

Test 57

Verdict:

input
)))((()((((((()()))(())(()(())...

correct output
(((()))(())(())(((((()())()(()...

user output
()()((((()))))((()(((((()))(()...

Test 58

Verdict: ACCEPTED

input
(()))((((((())(((()))))(())())...

correct output
(()()(()((()(((()(((()()()()((...

user output
(()()(()((()(((()(((()()()()((...

Test 59

Verdict: ACCEPTED

input
((((((((((((((((((((((((((((((...

correct output
((((((((((((((((((((((((((((((...

user output
((((((((((((((((((((((((((((((...

Test 60

Verdict: ACCEPTED

input
))))))))))))))))))))))))))))))...

correct output
-1

user output
-1

Test 61

Verdict: ACCEPTED

input
())(())(()()()(()()()))((())((...

correct output
(()(()()()(()())(())((((((()((...

user output
(()(()()()(()())(())((((((()((...

Test 62

Verdict:

input
))))))))))))))))))))))))))))))...

correct output
((((((((((((((((((((((((((((((...

user output
-1

Test 63

Verdict: ACCEPTED

input
()(())()()()(((((())))(((()())...

correct output
(()()((((())()()())())))((())(...

user output
(()()((((())()()())())))((())(...

Test 64

Verdict: ACCEPTED

input
()(())((()))(((())))((((()))))...

correct output
()(())((()))(((())))((((()))))...

user output
()(())((()))(((())))((((()))))...

Test 65

Verdict:

input
()(((((((()(((((((((()())())))...

correct output
()(((((()()))()))()(())(((()((...

user output
(((())((())(())(((()(()()(()()...