QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#490343#7683. Hard Brackets Problemucup-team3160#RE 0ms0kbC++14594b2024-07-25 14:46:252024-07-25 14:46:25

Judging History

你现在查看的是最新测评结果

  • [2024-07-25 14:46:25]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [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
((()))
(
)))()

output:


result: