QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#800600#7683. Hard Brackets ProblemUESTC_DebugSimulator#WA 8ms3644kbC++17475b2024-12-06 13:16:302024-12-06 13:16:31

Judging History

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

  • [2024-12-06 13:16:31]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3644kb
  • [2024-12-06 13:16:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
string work(){
	string s;
	cin>>s;
	int fl=0,nw=0;
	string ans;
	for(auto c:s){
		if(c=='('){
			while(nw){
				ans+=')';
				nw--;
			}
			fl++;
			ans+='(';
		}
		else{
			if(fl==0)ans+=')';
			else{
				fl--;
				nw++;
			}
		}
	}
	if(fl>0)return "impossible";
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T;
	cin>>T;
	while(T--)cout<<work()<<"\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 8ms
memory: 3644kb

input:

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

output:

impossible
()())())
)()()()(
impossible
((())()
impossible
)()))()))
impossible
impossible
()((()(
(()())()
())(()))(
(())(())
impossible
impossible
()((())(
()))()))(
()((())(
impossible
()))(()
(()(()
())(((
impossible
(()(()
impossible
impossible
impossible
impossible
impossible
())(()))(
impossi...

result:

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