QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#276135#7683. Hard Brackets Problemyujie3WA 31ms3748kbC++20423b2023-12-05 16:55:062023-12-05 16:55:06

Judging History

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

  • [2023-12-05 16:55:06]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:3748kb
  • [2023-12-05 16:55:06]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

int n;

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

signed main(){
	int t; cin >> t;
	while(t --){
		solve();
	} return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 31ms
memory: 3748kb

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)