QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#644395 | #7683. Hard Brackets Problem | aYi_7# | WA | 14ms | 3804kb | C++17 | 837b | 2024-10-16 13:42:27 | 2024-10-16 13:42:28 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
const int INF = 1e9 + 7;
void solve() {
std::string s;
std::cin >> s;
int l = 0, r = s.size() - 1;
std::vector<char> ans;
while(l <= r) {
if(s[l] == '(') {
if(s[r] == ')') {
l++, r--;
ans.emplace_back('(');
}
else {
std::cout << "impossible\n";
return ;
}
}
else {
l++;
ans.emplace_back(')');
}
}
for(auto &i : ans) std::cout << i;
std::cout << '\n';
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
std::cin >> t;
for (int i = 0; i < t; ++i) {
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: 14ms
memory: 3588kb
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)