QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#613997#7683. Hard Brackets ProblemPepinotWA 23ms3772kbC++20822b2024-10-05 15:18:052024-10-05 15:20:24

Judging History

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

  • [2024-10-05 15:20:24]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:3772kb
  • [2024-10-05 15:18:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

void solveTS() {
    string s; cin >> s;
    string ss;
    vector<char> ans;
    stack<char> sk;
    for(auto i:s) {
        if(i=='(') sk.push(i);
        else{
            if(sk.size()&&sk.top()=='(') {
                sk.pop();
                ans.push_back('(');
            }
            else {
                sk.push(i);
                ans.push_back(')');
            }
        }
    }
    // while(sk.size()) {
    //     cout<<sk.top();
    //     sk.pop();
    // }
    if(ans.empty()) cout<<"impossible";
    for(auto i:ans) cout<<i;
    cout<<endl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while(t--){
        solveTS();
    }
}
    /*
3
((()))
(
)))()

     */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3772kb

input:

3
((()))
(
)))()

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 23ms
memory: 3592kb

input:

100000
())(()()()
()())()))
)()()()()
())()(())(
((())()))
)(())()))(
)()))())))
)))))(((()
()))((()((
()((()()))
(()())())
())(()))()
(())(())))
))))(()(()
()))(())((
()((())())
()))()))()
()((())())
()()))((()
()))(()))
(()(())))
())((()))
())()((())
(()(())))
()(((()())
))))())))(
((((()()()
(()(...

output:

()(((
(()())
)((((
()(((
(((()
)((())
)())()))
)))))(
())(
(((((
(((()
()(()(
(((())
))))((
())((
(((((
())())(
(((((
(())(
())(()
(((()
()(((
()(((
(((()
((((
))))()))
(((
((((
)(((
()(()(
))(((
(((()
)()(
)))(()(
(()()(
((()()
(((()
)(((
(((()
)((((
(((()
)(((()
()((()
(((()
)))))((
))))(((
)()((
...

result:

wrong answer the result string is incorrect (test case 1)