QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#490343 | #7683. Hard Brackets Problem | ucup-team3160# | RE | 0ms | 0kb | C++14 | 594b | 2024-07-25 14:46:25 | 2024-07-25 14:46:25 |
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 ;
}
for ( int i = 1 ; i <= n ; i++ ) printf("%s" , 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: 0
Runtime Error
input:
3 ((())) ( )))()