QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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;
}
详细
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)