QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#275819#7683. Hard Brackets Problemship2077WA 10ms3836kbC++14407b2023-12-05 08:41:262023-12-05 08:41:27

Judging History

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

  • [2023-12-05 08:41:27]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:3836kb
  • [2023-12-05 08:41:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=1e6+5;bool fl;
char s[M],t[M];int n,m,T;
int main(){
	scanf("%d",&T);
	while (T--){ fl=m=0;
		scanf("%s",s+1);n=strlen(s+1);
		for (int i=1;i<=n;i++)
			if (s[i]==')') t[++m]=')';
			else if (s[n]==')')
				t[++m]='(',n--;
			else {fl=1;break;}
		if (fl) puts("impossible");
		else t[m+1]='\0',printf("%s\n",t+1);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

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

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)