QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#645865#7683. Hard Brackets ProblemE_REMALWA 56ms3676kbC++14595b2024-10-16 20:11:562024-10-16 20:11:56

Judging History

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

  • [2024-10-16 20:11:56]
  • 评测
  • 测评结果:WA
  • 用时:56ms
  • 内存:3676kb
  • [2024-10-16 20:11:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,l,r;
string s;
vector <int> ans;
bool b;
int main()
{
	cin>>n;
	while(n--) {
		cin>>s;
		l=0;
		r=s.length()-1;
		b=1;
		ans.clear();
		while(l<=r) {
			if(s[r]=='(') {
				b=0;
				break;
			}
			if(s[l]=='(' && s[r]==')' ) {
				ans.push_back(0);
				l++;
				r--;
			}
			else if(s[l]==')') {
				ans.push_back(1);
				l++;
			}
		}
		if(b==0) cout<<"impossible"<<endl;
		else {
			for(int i=0;i<ans.size();i++) {
				if(ans[i]==0) cout<<'(';
				else cout<<')';
			}
			cout<<endl;
		}
}
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 56ms
memory: 3616kb

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)