QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#662049#7683. Hard Brackets ProblemxDarkbluexWA 1ms3644kbC++17588b2024-10-20 20:18:402024-10-20 20:18:49

Judging History

你现在查看的是最新测评结果

  • [2024-10-20 20:18:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3644kb
  • [2024-10-20 20:18:40]
  • 提交

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)