QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#662049 | #7683. Hard Brackets Problem | xDarkbluex | WA | 1ms | 3644kb | C++17 | 588b | 2024-10-20 20:18:40 | 2024-10-20 20:18:49 |
Judging History
answer
#include <bits/stdc++.h>
void solve() {
std::string s;
std::cin >> s;
int len = s.size();
if (len == 1) {
if (s[0] == '(') std::cout << "impossible\n";
else std::cout << ")\n";
return;
}
std::stack<char> stk;
for (int i = 0; i < len; i++) {
if (s[i] == '(') stk.emplace('(');
else if (stk.size()) stk.pop();
}
if (stk.size()) std::cout << "impossible\n";
else std::cout << s;
}
int main() {
int T;
std::cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3644kb
input:
3 ((())) ( )))()
output:
((()))impossible )))()
result:
wrong answer the output is too long (test case 1)