QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#619346#7683. Hard Brackets Problemty09#WA 6ms3832kbC++17741b2024-10-07 13:56:092024-10-07 13:56:10

Judging History

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

  • [2024-10-07 13:56:10]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3832kb
  • [2024-10-07 13:56:09]
  • 提交

answer

// #pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0),cin.tie(nullptr),cout.tie(nullptr)
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define T() int ____t;cin>>____t;while(____t--)
using namespace std;
constexpr int N=2e6+10,mod=1e9+7;

#define int ll

void solve(){
	string s;
	cin>>s;
	int l=0,r=s.size()-1;
	string t;
	while(l<r)
	{
		if(s[l]==')')
		{
			t+=')';
			l++;
		}
		else
		{
			if(s[r]!=')')
			{
				cout << "impossible\n";
				return ;
			}
			t+='(';
			l++;
			r--;
		}
	}
	if(t.size()==0)
	{
		cout << "impossible\n";
		return ;
	}
	cout << t << "\n";
}
signed main()
{
	ios;
	T()
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 6ms
memory: 3832kb

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
impos...

result:

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