QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#490338 | #7683. Hard Brackets Problem | ucup-team3160# | WA | 24ms | 7712kb | C++14 | 551b | 2024-07-25 14:45:36 | 2024-07-25 14:45:36 |
Judging History
answer
# include <bits/stdc++.h>
using namespace std ;
int stk[1000005] , top ;
int n ;
char s[1000005] ;
int pre[100005] ;
void solve()
{
scanf("%s" , s + 1) ;
n = strlen( s + 1 ) ;
top = 0 ;
for ( int i = 1 ; i <= n ; i++ )
{
pre[i] = 0 ;
if ( s[i] == '(' )
{
stk[++ top] = i ;
}
else
{
if ( top ) pre[i] = stk[top --] ;
}
}
if ( top )
{
puts("impossible") ;
return ;
}
printf("%s\n" , s + 1) ;
}
int main()
{
int t ;
scanf("%d" , &t) ;
while ( t -- ) solve() ;
return 0 ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
3 ((())) ( )))()
output:
((())) impossible )))()
result:
ok 3 cases (3 test cases)
Test #2:
score: 0
Accepted
time: 13ms
memory: 3892kb
input:
100000 ())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) )))))(((() ()))((()(( ()((()())) (()())()) ())(()))() (())(()))) ))))(()(() ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) ()(((()()) ))))())))( ((((()()() (()(...
output:
impossible ()())())) )()()()() impossible ((())())) impossible )()))()))) impossible impossible ()((()())) (()())()) ())(()))() (())(()))) impossible impossible ()((())()) ()))()))() ()((())()) impossible ()))(())) (()(()))) ())((())) impossible (()(()))) impossible impossible impossible impossible ...
result:
ok 100000 cases (100000 test cases)
Test #3:
score: 0
Accepted
time: 17ms
memory: 5796kb
input:
200000 (())) ()))( )())) (()) )(((( )(()) )(()) ()))( ((()( ()(() ))()) )(((( ()()) (()) ()(() (()() )(()) ())) (()() ()()) (()) ()()( (()(( )()) (()() (()) ))((( (()) ())() ())() (())) ((((( )()) (())) ()(() )()() (())) ()()) (())) )(()) (())( ))))( ())(( ))((( ))))( ()() ()()) (()) (()) (()) )(())...
output:
(())) impossible )())) (()) impossible )(()) )(()) impossible impossible impossible ))()) impossible ()()) (()) impossible impossible )(()) ())) impossible ()()) (()) impossible impossible )()) impossible (()) impossible (()) ())() ())() (())) impossible )()) (())) impossible )()() (())) ()()) (()))...
result:
ok 200000 cases (200000 test cases)
Test #4:
score: 0
Accepted
time: 24ms
memory: 5796kb
input:
250000 ()() (()) ()) )((( (()( (()) )() (()) (()) ))() )(() )()) )()) (()) )()) ())) ()) (()( )))) ()(( ()() )()) ()) ()) ()) (()) ))() (()) (()( )))( ())) ()) )))( )(() ())) ()() (()) ((() (()) ))(( ))(( (()) ())) (()( (()) ((() )(() (()) (((( ()) ))() ()) ()() )()( )() (()) ))() ())) ()) )() )()) ...
output:
()() (()) ()) impossible impossible (()) )() (()) (()) ))() impossible )()) )()) (()) )()) ())) ()) impossible )))) impossible ()() )()) ()) ()) ()) (()) ))() (()) impossible impossible ())) ()) impossible impossible ())) ()() (()) impossible (()) impossible impossible (()) ())) impossible (()) impo...
result:
ok 250000 cases (250000 test cases)
Test #5:
score: 0
Accepted
time: 7ms
memory: 3800kb
input:
50000 )))()((((()(((())(() )(())()())((())))()( (((((()))()(((()((() )()(()())(()())(()() ()(())()()()((()))) )((())))((((())((((( ((())(()()))()(()()) ()))())(()))(()())(( ))(((())(())()))()) ((((()())()))()((((( ((())()))))(((())))) ()()(())((()(())))) ()())())))()()(())) ()))(())()())()(()) ()()(...
output:
impossible impossible impossible impossible ()(())()()()((()))) impossible ((())(()()))()(()()) impossible ))(((())(())()))()) impossible ((())()))))(((())))) ()()(())((()(())))) ()())())))()()(())) ()))(())()())()(()) impossible )))))(())()())((())) impossible )(((()())()(())())) impossible impossi...
result:
ok 50000 cases (50000 test cases)
Test #6:
score: 0
Accepted
time: 8ms
memory: 3792kb
input:
83333 ((()((())(() (())(()())) ()(()(()))) ((((()))))) )())(((()))) ()()())()()) ()()((()))) (()(()(((()) ()((()()()() (()()()()))) (()()()(((() )))))()()()) )((()()()))) ))(((())))) ()())(()))() )()))))()()) )(()((())))( (()())(())) ())()((()))) (()()()(())) )())()()(()) ((())()))(() (()(()(((()) )...
output:
impossible (())(()())) ()(()(()))) ((((()))))) )())(((()))) ()()())()()) ()()((()))) impossible impossible (()()()()))) impossible )))))()()()) )((()()()))) ))(((())))) ()())(()))() )()))))()()) impossible (()())(())) ())()((()))) (()()()(())) )())()()(()) impossible impossible impossible impossible...
result:
ok 83333 cases (83333 test cases)
Test #7:
score: 0
Accepted
time: 23ms
memory: 3792kb
input:
250000 ))) )((( ()() ((() ((() ()) ())( ))(( )()) ()() ()() ()) ((() ()) ()() (()) (()) ()() ())) ()) )()) ()() )() ()) )()( (()) )() )((( ))() (()) )() )()) )() )() ))(( ()() (()) ()(( ))(( )((( ())) )()) )()) )()) )()) )((( ()) ))) (()) (()) ())( ()) (()) (()) ()() ())( ()() ()) ))() (()) (()) )()...
output:
))) impossible ()() impossible impossible ()) impossible impossible )()) ()() ()() ()) impossible ()) ()() (()) (()) ()() ())) ()) )()) ()() )() ()) impossible (()) )() impossible ))() (()) )() )()) )() )() impossible ()() (()) impossible impossible impossible ())) )()) )()) )()) )()) impossible ())...
result:
ok 250000 cases (250000 test cases)
Test #8:
score: 0
Accepted
time: 10ms
memory: 5800kb
input:
50000 (())((()()(())(((()( ()()()((((()())()))) (())(()()()((())))() (())(()))(()(()())) ()((((()((()))))))) )))())))()()())()))( ()(()))(((())()((((( ()()())())(((()()))) (())(())))(()((()))) ()(()(())()()()()((( ()()()((()(()())))) )(())))()(())()())() )((((((()())())((()) )()())(()((()(())))) (()...
output:
impossible ()()()((((()())()))) (())(()()()((())))() (())(()))(()(()())) ()((((()((()))))))) impossible impossible ()()())())(((()()))) (())(())))(()((()))) impossible ()()()((()(()())))) )(())))()(())()())() impossible )()())(()((()(())))) (())(()()())()())()) )())()()()()((())()) (())()((())((()))...
result:
ok 50000 cases (50000 test cases)
Test #9:
score: 0
Accepted
time: 13ms
memory: 3804kb
input:
83333 ((()(())))() ()))()()))() ()))()))())( ())(())))()) )()))))((((( )(()(()())(( (()))(())()) )()()()(()() ((()())((()) )())()()(()( ()(())()()) )(()(())()) ()(())(())) ))()(()(())( ()((()()))) )()(((()))) )())()()))) (((()()()))) ()())()())() ()())(())() )()((()())(( (()()((((()) (())))()())) ((...
output:
((()(())))() ()))()()))() impossible ())(())))()) impossible impossible (()))(())()) impossible impossible impossible ()(())()()) )(()(())()) ()(())(())) impossible ()((()()))) )()(((()))) )())()()))) (((()()()))) ()())()())() ()())(())() impossible impossible (())))()())) ((((()))))) impossible ())...
result:
ok 83333 cases (83333 test cases)
Test #10:
score: 0
Accepted
time: 20ms
memory: 5796kb
input:
250000 )()) ())) ())( (()) ()() ()) ))(( ()) )() ()) ()(( ())) (()) )((( ()) (()) ))() )()) (()( )() (((( ())) )))( (()( ()() )))) )()) ()() ((() )((( ()() (()) )(() ()() )() )))( ()) ())( ()) )))( ))() ()) )()) ))(( ()) ())) ((() )()( )() ())) ()) )()) (()) (()( ()() ())) ())) )))( ())) )() ()) ())...
output:
)()) ())) impossible (()) ()() ()) impossible ()) )() ()) impossible ())) (()) impossible ()) (()) ))() )()) impossible )() impossible ())) impossible impossible ()() )))) )()) ()() impossible impossible ()() (()) impossible ()() )() impossible ()) impossible ()) impossible ))() ()) )()) impossible ...
result:
ok 250000 cases (250000 test cases)
Test #11:
score: 0
Accepted
time: 7ms
memory: 3804kb
input:
50000 (())(()(()(())))()) ())()()))(())()()()) ())()())((()(())))) ()(()()))(()((()))) ()))))()))((()((())) ()(())())())(()))()) ((()((()((())))()))) ())()))()()()()))))) (((()()))))))()(()) ))(()((())((((()(((( ()((()()(((()()()()) (()())(()(()))()))) ()()))))(()(()()())) ())()())(((()(())))) ()(((...
output:
(())(()(()(())))()) ())()()))(())()()()) ())()())((()(())))) ()(()()))(()((()))) impossible ()(())())())(()))()) ((()((()((())))()))) ())()))()()()()))))) (((()()))))))()(()) impossible impossible (()())(()(()))()))) ()()))))(()(()()())) ())()())(((()(())))) ()((()(()))()(()))) impossible ()))())(()...
result:
ok 50000 cases (50000 test cases)
Test #12:
score: 0
Accepted
time: 13ms
memory: 5796kb
input:
83333 ())()))))(() (()((()(())) ((((((()())( ())(((((())) ((())((()))) )())())))))( ()(((())((() ()(((())))) (()))((())) )(())())(((( )()()()(()) )(()))(()))) )(((()()))) )(())(()())) (())))(()))( (((((()))))( ))((()()())( (((()))())() (((()()((()) ())))))((((( ()((((())))) )()(()))(()) (()))(()()))...
output:
impossible impossible impossible impossible ((())((()))) impossible impossible ()(((())))) (()))((())) impossible )()()()(()) )(()))(()))) )(((()()))) )(())(()())) impossible impossible impossible (((()))())() impossible impossible ()((((())))) )()(()))(()) (()))(()())) )())))()())) impossible (())(...
result:
ok 83333 cases (83333 test cases)
Test #13:
score: 0
Accepted
time: 23ms
memory: 5860kb
input:
250000 (()) (((( (()) ()) ()() (()) (()) ()) ))() (()) ))() (()) ())) )))) (()) ())) ())) ()) )()( ))) )()) (()) (()) ))() (()) ()) ())) ))() ))(( )() ()() )((( (()) ()() )() )(() ()) )()) ((() ))() )((( ())) ()) ()) )()) ())) )()) (()) ))() )))) )()) ()) ))() )()( )))) (((( ()) (()) )() )()) ()) ()...
output:
(()) impossible (()) ()) ()() (()) (()) ()) ))() (()) ))() (()) ())) )))) (()) ())) ())) ()) impossible ))) )()) (()) (()) ))() (()) ()) ())) ))() impossible )() ()() impossible (()) ()() )() impossible ()) )()) impossible ))() impossible ())) ()) ()) )()) ())) )()) (()) ))() )))) )()) ()) ))() impo...
result:
ok 250000 cases (250000 test cases)
Test #14:
score: 0
Accepted
time: 10ms
memory: 5848kb
input:
50000 ))(())())())()(()(() )((())((()()))(()))) ()(()(()))()(()())) ((()())()())(()(())) )()()(())())()(())() (()(()(((())))()())) ((()))()()(()(()((() ()()()()(())(((()))) )))))((((()()()()((( ((())((()()(()))))) (((((()()()(())))))) ())())))())())()(()) ((())((((((()))))))) ((())()())())()()()) ()...
output:
impossible )((())((()()))(()))) ()(()(()))()(()())) ((()())()())(()(())) )()()(())())()(())() (()(()(((())))()())) impossible ()()()()(())(((()))) impossible ((())((()()(()))))) (((((()()()(())))))) ())())))())())()(()) ((())((((((()))))))) ((())()())())()()()) ()((((()(((()))))))) ()())(((()))((())...
result:
ok 50000 cases (50000 test cases)
Test #15:
score: 0
Accepted
time: 13ms
memory: 5856kb
input:
83333 )))((())(()( ()((()))()) (()))()(()(( ))((()()(()( (()))()())) )))()()(()(( )(()))()()(( ())((())))) (())))()()) )(()()))(()( ()(()()))() ()))())())(( ((()(()()))) (((())()()() ()(())(()()) ))())((())) ())((()()(() ))(()((()))) ((((()())))) (()((())())( )()())(())() ))(()())())) (()(())(()() (...
output:
impossible ()((()))()) impossible impossible (()))()())) impossible impossible ())((())))) (())))()()) impossible ()(()()))() impossible ((()(()()))) impossible ()(())(()()) ))())((())) impossible ))(()((()))) ((((()())))) impossible )()())(())() ))(()())())) impossible ())(())()() impossible imposs...
result:
ok 83333 cases (83333 test cases)
Test #16:
score: -100
Wrong Answer
time: 4ms
memory: 7712kb
input:
1 (()()((((())))(((((((())(()())())()(()((()(((()(()))))())((())((())((()))()())(()))()))((())()())))()())()(()((())(((()()(((())(((()))(((()())((()(((()())()())(()(()(())()()())())(((((((()((((()))()())())((((()(()())()())))((()((((()(((((()((((())()(()(()((((()()(((())())())))(())))))))))((((()(()...
output:
result:
wrong answer the answer string contains illegal characters (test case 1)