QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#654325 | #7683. Hard Brackets Problem | Sound_Medium | WA | 11ms | 3624kb | C++23 | 553b | 2024-10-18 21:24:48 | 2024-10-18 21:24:57 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m;
void solve () {
string s;
cin>>s;
string ans;
int cnt=0;
for(int i=0;i<s.size();i++){
if(s[i]=='('){
cnt++;
ans.push_back('(');
}
else if(s[i]==')'){
if(cnt>0){
cnt--;
}else{
ans.push_back(')');
}
}
}
if(cnt){
cout<<"impossible\n";
}else{
cout<<ans<<endl;
}
}
signed main () {
int T = 1;
std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin>>T;
while (T --) solve ();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
3 ((())) ( )))()
output:
((( impossible )))(
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 11ms
memory: 3584kb
input:
100000 ())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) )))))(((() ()))((()(( ()((()())) (()())()) ())(()))() (())(()))) ))))(()(() ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) ()(((()()) ))))())))( ((((()()() (()(...
output:
impossible (()()) )(((( impossible (((() impossible )())())) impossible impossible ((((( (((() ()(()( (((()) impossible impossible ((((( ())())( ((((( impossible ())(() (((() ()((( impossible (((() impossible impossible impossible impossible impossible ()(()( impossible impossible impossible )))(()(...
result:
wrong answer the result string is incorrect (test case 2)