QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619374#7683. Hard Brackets Problemty09#WA 8ms3556kbC++17762b2024-10-07 14:01:192024-10-07 14:01:21

Judging History

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

  • [2024-10-07 14:01:21]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3556kb
  • [2024-10-07 14:01:19]
  • 提交

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;
	string t;
	int l=0;
	int r=s.size()-1;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]==')')
		{
			t+=s[i];
		}
		else
		{
			l=i;
			break;
		}
	}
	while(l<=r)
	{
		if(s[l]=='('&&s[r]==')')
		{
			t+=s[l];
			l++;
			r--;
		}
		else
		{
			cout << "impossible\n";
			return ;
		}
	}
	
	cout << t << "\n";
}
signed main()
{
	ios;
	T()
	solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3556kb

input:

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

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

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

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
impossible
impossible
impossible
impossible
imp...

result:

wrong answer Jury has the answer but participant has not (test case 2)