QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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;
}
Details
Tip: Click on the bar to expand more detailed information
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)