QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#257859 | #7683. Hard Brackets Problem | daydream# | WA | 10ms | 3748kb | C++20 | 430b | 2023-11-19 13:24:54 | 2023-11-19 13:24:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int infi=1e9;
int n;
void solve()
{
string s,ans;cin>>s;
n=s.size();s=" "+s;
for(int l=1,r=n;l<=r;++l)
if(s[l]=='(')
{
if(s[r]!=')') return cout<<"impossible\n",void();
ans+='(';r--;
}
else ans+=')';
cout<<ans<<'\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int TT=1;
cin>>TT;
for(;TT;--TT) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3748kb
input:
3 ((())) ( )))()
output:
((( impossible )))(
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 3596kb
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 impos...
result:
wrong answer the result string is incorrect (test case 2)