QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#656710 | #7683. Hard Brackets Problem | nidehg | WA | 69ms | 3804kb | C++20 | 469b | 2024-10-19 13:35:44 | 2024-10-19 13:35:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int t;
void solve(){
string s;
cin >> s;
int cnt1 = 0, cnt2 = 0;
vector<char> a;
for (auto v : s){
if (v == '('){
cnt1 ++ ;
}
else {
cnt2 ++ ;
}
a.push_back(v);
}
if (cnt1 <= cnt2){
for (auto v : a){
cout << v;
}
cout << '\n';
}
else {
cout << "impossible\n";
}
}
int main(){
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: 3804kb
input:
3 ((())) ( )))()
output:
((())) impossible )))()
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 69ms
memory: 3604kb
input:
100000 ())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) )))))(((() ()))((()(( ()((()())) (()())()) ())(()))() (())(()))) ))))(()(() ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) ()(((()()) ))))())))( ((((()()() (()(...
output:
())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) )))))(((() impossible ()((()())) (()())()) ())(()))() (())(()))) ))))(()(() ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) impossible ))))())))( impossible impossible ...
result:
wrong answer the result string is incorrect (test case 1)