Task: | Bracket sequence |
Sender: | aalto2024j_002 |
Submission time: | 2024-11-06 17:28:56 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.00 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.00 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.00 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | ACCEPTED | 0.00 s | details |
#32 | ACCEPTED | 0.00 s | details |
#33 | ACCEPTED | 0.00 s | details |
#34 | ACCEPTED | 0.00 s | details |
#35 | ACCEPTED | 0.00 s | details |
#36 | ACCEPTED | 0.00 s | details |
#37 | ACCEPTED | 0.00 s | details |
#38 | ACCEPTED | 0.00 s | details |
#39 | ACCEPTED | 0.00 s | details |
#40 | ACCEPTED | 0.00 s | details |
#41 | ACCEPTED | 0.00 s | details |
#42 | ACCEPTED | 0.00 s | details |
#43 | ACCEPTED | 0.00 s | details |
#44 | ACCEPTED | 0.00 s | details |
#45 | ACCEPTED | 0.00 s | details |
#46 | ACCEPTED | 0.00 s | details |
#47 | ACCEPTED | 0.00 s | details |
#48 | ACCEPTED | 0.00 s | details |
#49 | ACCEPTED | 0.00 s | details |
#50 | ACCEPTED | 0.00 s | details |
#51 | ACCEPTED | 0.00 s | details |
#52 | ACCEPTED | 0.00 s | details |
#53 | ACCEPTED | 0.00 s | details |
#54 | ACCEPTED | 0.00 s | details |
#55 | ACCEPTED | 0.00 s | details |
#56 | ACCEPTED | 0.17 s | details |
#57 | ACCEPTED | 0.16 s | details |
#58 | ACCEPTED | 0.16 s | details |
#59 | ACCEPTED | 0.15 s | details |
#60 | ACCEPTED | 0.16 s | details |
#61 | ACCEPTED | 0.15 s | details |
#62 | ACCEPTED | 0.16 s | details |
#63 | ACCEPTED | 0.15 s | details |
#64 | ACCEPTED | 0.15 s | details |
#65 | ACCEPTED | 0.15 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:19:19: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare] 19 | for(int i=0; i<strlen(s); i++) | ~^~~~~~~~~~ input/code.cpp: In function 'void Test()': input/code.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result] 8 | freopen("temp\\in.txt", "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ input/code.cpp: In function 'int main()': input/code.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result] 14 | scanf("%s", s); | ~~~~~^~~~~~~~~
Code
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int N=100005; void Test() { freopen("temp\\in.txt", "r", stdin); } char s[N]; int main() { // Test(); scanf("%s", s); string ans; stack<int> sta; sta.push(-1); int mx = 0, id = 0; for(int i=0; i<strlen(s); i++) { if(s[i] == '(') { sta.push(i); } else { sta.pop(); if(sta.empty()) { sta.push(i); } else { if(i - sta.top() > mx) { mx = i - sta.top(); id = i; } } } } if(mx > 0) for(int i = 0; i<mx; i++) putchar(s[id-mx+i+1]); else cout << "-1"; return 0; }
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: ACCEPTED
input |
---|
(() |
correct output |
---|
() |
user output |
---|
() |
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: ACCEPTED
input |
---|
(()( |
correct output |
---|
() |
user output |
---|
() |
Test 10
Verdict: ACCEPTED
input |
---|
))))) |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 11
Verdict: ACCEPTED
input |
---|
())(() |
correct output |
---|
() |
user output |
---|
() |
Test 12
Verdict: ACCEPTED
input |
---|
))(()( |
correct output |
---|
() |
user output |
---|
() |
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: ACCEPTED
input |
---|
)))((()((( |
correct output |
---|
() |
user output |
---|
() |
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: ACCEPTED
input |
---|
)((())(()( |
correct output |
---|
(()) |
user output |
---|
(()) |
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: ACCEPTED
input |
---|
((((((())))))))(((((((((()))))... |
correct output |
---|
(((((())))))(((((((((()))))(((... |
user output |
---|
(((((())))))(((((((((()))))(((... |
Test 27
Verdict: ACCEPTED
input |
---|
)))((()((((((()()))(())(()(())... |
correct output |
---|
((()((((((()()))(())(()(()))((... |
user output |
---|
((()((((((()()))(())(()(()))((... |
Test 28
Verdict: ACCEPTED
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: ACCEPTED
input |
---|
(((((((((()))))))))((((((((())... |
correct output |
---|
((((((((())))))))) |
user output |
---|
((((((((())))))))) |
Test 33
Verdict: ACCEPTED
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: ACCEPTED
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: ACCEPTED
input |
---|
))))(((((((((((((())))))))))))... |
correct output |
---|
((((((((((((())))))))))))) |
user output |
---|
((((((((((((())))))))))))) |
Test 43
Verdict: ACCEPTED
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: ACCEPTED
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: ACCEPTED
input |
---|
())(())(()()()(()()()))((())((... |
correct output |
---|
(((()((((((()(((((()(((()(((()... |
user output |
---|
(((()((((((()(((((()(((()(((()... |
Test 52
Verdict: ACCEPTED
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: ACCEPTED
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: ACCEPTED
input |
---|
))))))))))))))))))))))))))))))... |
correct output |
---|
((((((((((((((((((((((((((((((... |
user output |
---|
((((((((((((((((((((((((((((((... |
Test 63
Verdict: ACCEPTED
input |
---|
()(())()()()(((((())))(((()())... |
correct output |
---|
(()()((((())()()())())))((())(... |
user output |
---|
(()()((((())()()())())))((())(... |
Test 64
Verdict: ACCEPTED
input |
---|
()(())((()))(((())))((((()))))... |
correct output |
---|
()(())((()))(((())))((((()))))... |
user output |
---|
()(())((()))(((())))((((()))))... |
Test 65
Verdict: ACCEPTED
input |
---|
()(((((((()(((((((((()())())))... |
correct output |
---|
()(((((()()))()))()(())(((()((... |
user output |
---|
()(((((()()))()))()(())(((()((... |