QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#647514#7683. Hard Brackets ProblemKOH-#WA 10ms3720kbC++14532b2024-10-17 14:32:122024-10-17 14:32:13

Judging History

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

  • [2024-10-17 14:32:13]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:3720kb
  • [2024-10-17 14:32:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
char a[N],b[N];
int n,m;
void solve(){
	scanf("%s",a+1);
	n=strlen(a+1);
	m=0;
	for(int i=1;i<=n;i++){
		if(a[i]==')'){
			m++;
			b[m]=')';
		}
		else{
			if(n<=i){
				puts("impossible");
				return ;
			}
			if(a[n]==')'){
				n--;
				m++;
				b[m]='(';
			}
			else{
				puts("impossible");
				return ;
			}
		}
	}
	for(int i=1;i<=m;i++) putchar(b[i]);
	puts("");
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3664kb

input:

3
((()))
(
)))()

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 10ms
memory: 3720kb

input:

100000
())(()()()
()())()))
)()()()()
())()(())(
((())()))
)(())()))(
)()))())))
)))))(((()
()))((()((
()((()()))
(()())())
())(()))()
(())(())))
))))(()(()
()))(())((
()((())())
()))()))()
()((())())
()()))((()
()))(()))
(()(())))
())((()))
())()((())
(()(())))
()(((()())
))))())))(
((((()()()
(()(...

output:

impossible
()())(
impossible
impossible
impossible
impossible
)()))())
impossible
impossible
impossible
impossible
impossible
(())((
impossible
impossible
impossible
impossible
impossible
impossible
()))((
(()((
impossible
impossible
(()((
impossible
impossible
impossible
impossible
impossible
impos...

result:

wrong answer the result string is incorrect (test case 2)