QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#619346 | #7683. Hard Brackets Problem | ty09# | WA | 6ms | 3832kb | C++17 | 741b | 2024-10-07 13:56:09 | 2024-10-07 13:56:10 |
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;
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)