QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619374 | #7683. Hard Brackets Problem | ty09# | WA | 8ms | 3556kb | C++17 | 762b | 2024-10-07 14:01:19 | 2024-10-07 14:01:21 |
Judging History
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)