QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#257859#7683. Hard Brackets Problemdaydream#WA 10ms3748kbC++20430b2023-11-19 13:24:542023-11-19 13:24:55

Judging History

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

  • [2023-11-19 13:24:55]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:3748kb
  • [2023-11-19 13:24:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int infi=1e9;

int n;
void solve()
{
	string s,ans;cin>>s;
	n=s.size();s=" "+s;
	for(int l=1,r=n;l<=r;++l)
		if(s[l]=='(')
		{
			if(s[r]!=')') return cout<<"impossible\n",void();
			ans+='(';r--;
		}
		else ans+=')';
	cout<<ans<<'\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int TT=1;
	cin>>TT;
	for(;TT;--TT) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

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

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)