QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#644395#7683. Hard Brackets ProblemaYi_7#WA 14ms3804kbC++17837b2024-10-16 13:42:272024-10-16 13:42:28

Judging History

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

  • [2024-10-16 13:42:28]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3804kb
  • [2024-10-16 13:42:27]
  • 提交

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)