QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#490354 | #7683. Hard Brackets Problem | ucup-team3160# | WA | 35ms | 7760kb | C++14 | 577b | 2024-07-25 14:49:03 | 2024-07-25 14:49:03 |
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] == '(' )
{
top++ ;
}
else
{
top = max( top - 1 , 0 ) ;
}
}
if ( top )
{
puts("impossible") ;
return ;
}
for ( int i = 1 ; i <= n ; i++ ) printf("%c" , s[i]) ;
puts("") ;
}
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: 3812kb
input:
3 ((())) ( )))()
output:
((())) impossible )))()
result:
ok 3 cases (3 test cases)
Test #2:
score: 0
Accepted
time: 27ms
memory: 5856kb
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: 31ms
memory: 5804kb
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: 34ms
memory: 5804kb
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: 21ms
memory: 5852kb
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: 26ms
memory: 3764kb
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: 31ms
memory: 5780kb
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: 23ms
memory: 3796kb
input:
50000 (())((()()(())(((()( ()()()((((()())()))) (())(()()()((())))() (())(()))(()(()())) ()((((()((()))))))) )))())))()()())()))( ()(()))(((())()((((( ()()())())(((()()))) (())(())))(()((()))) ()(()(())()()()()((( ()()()((()(()())))) )(())))()(())()())() )((((((()())())((()) )()())(()((()(())))) (()...
output:
impossible ()()()((((()())()))) (())(()()()((())))() (())(()))(()(()())) ()((((()((()))))))) impossible impossible ()()())())(((()()))) (())(())))(()((()))) impossible ()()()((()(()())))) )(())))()(())()())() impossible )()())(()((()(())))) (())(()()())()())()) )())()()()()((())()) (())()((())((()))...
result:
ok 50000 cases (50000 test cases)
Test #9:
score: 0
Accepted
time: 26ms
memory: 5852kb
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: 35ms
memory: 5856kb
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: 24ms
memory: 3736kb
input:
50000 (())(()(()(())))()) ())()()))(())()()()) ())()())((()(())))) ()(()()))(()((()))) ()))))()))((()((())) ()(())())())(()))()) ((()((()((())))()))) ())()))()()()()))))) (((()()))))))()(()) ))(()((())((((()(((( ()((()()(((()()()()) (()())(()(()))()))) ()()))))(()(()()())) ())()())(((()(())))) ()(((...
output:
(())(()(()(())))()) ())()()))(())()()()) ())()())((()(())))) ()(()()))(()((()))) impossible ()(())())())(()))()) ((()((()((())))()))) ())()))()()()()))))) (((()()))))))()(()) impossible impossible (()())(()(()))()))) ()()))))(()(()()())) ())()())(((()(())))) ()((()(()))()(()))) impossible ()))())(()...
result:
ok 50000 cases (50000 test cases)
Test #12:
score: 0
Accepted
time: 26ms
memory: 3808kb
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: 3828kb
input:
250000 (()) (((( (()) ()) ()() (()) (()) ()) ))() (()) ))() (()) ())) )))) (()) ())) ())) ()) )()( ))) )()) (()) (()) ))() (()) ()) ())) ))() ))(( )() ()() )((( (()) ()() )() )(() ()) )()) ((() ))() )((( ())) ()) ()) )()) ())) )()) (()) ))() )))) )()) ()) ))() )()( )))) (((( ()) (()) )() )()) ()) ()...
output:
(()) impossible (()) ()) ()() (()) (()) ()) ))() (()) ))() (()) ())) )))) (()) ())) ())) ()) impossible ))) )()) (()) (()) ))() (()) ()) ())) ))() impossible )() ()() impossible (()) ()() )() impossible ()) )()) impossible ))() impossible ())) ()) ()) )()) ())) )()) (()) ))() )))) )()) ()) ))() impo...
result:
ok 250000 cases (250000 test cases)
Test #14:
score: 0
Accepted
time: 17ms
memory: 5808kb
input:
50000 ))(())())())()(()(() )((())((()()))(()))) ()(()(()))()(()())) ((()())()())(()(())) )()()(())())()(())() (()(()(((())))()())) ((()))()()(()(()((() ()()()()(())(((()))) )))))((((()()()()((( ((())((()()(()))))) (((((()()()(())))))) ())())))())())()(()) ((())((((((()))))))) ((())()())())()()()) ()...
output:
impossible )((())((()()))(()))) ()(()(()))()(()())) ((()())()())(()(())) )()()(())())()(())() (()(()(((())))()())) impossible ()()()()(())(((()))) impossible ((())((()()(()))))) (((((()()()(())))))) ())())))())())()(()) ((())((((((()))))))) ((())()())())()()()) ()((((()(((()))))))) ()())(((()))((())...
result:
ok 50000 cases (50000 test cases)
Test #15:
score: 0
Accepted
time: 25ms
memory: 3736kb
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: 7760kb
input:
1 (()()((((())))(((((((())(()())())()(()((()(((()(()))))())((())((())((()))()())(()))()))((())()())))()())()(()((())(((()()(((())(((()))(((()())((()(((()())()())(()(()(())()()())())(((((((()((((()))()())())((((()(()())()())))((()((((()(((((()((((())()(()(()((((()()(((())())())))(())))))))))((((()(()...
output:
result:
wrong answer the answer string contains illegal characters (test case 1)