QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#544216#7683. Hard Brackets Problemucup-team2179#WA 3ms3532kbC++20772b2024-09-02 12:39:362024-09-02 12:39:37

Judging History

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

  • [2024-09-02 12:39:37]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3532kb
  • [2024-09-02 12:39:36]
  • 提交

answer

#include<bits/stdc++.h>
// #define int long long
#define pii pair<int, int>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 998244353;
void solve() {
    string str;
    cin >> str;
    int n = str.length();
    for (int i = 0; i < n; i++) {
        if (str[i] == ')') continue;
        int sum = 0;
        for (int j = i; j < n; j++) {
            if (str[j] == '(')
                sum++;
            else
                sum--;
        }
        if (sum > 0) {
            cout << "impossible\n";
            return;
        }
        break;
    }
    cout << str << "\n";
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t; cin >> t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3528kb

input:

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

output:

((()))
impossible
)))()

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3532kb

input:

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

output:

())(()()()
()())()))
)()()()()
())()(())(
((())()))
)(())()))(
)()))())))
impossible
impossible
()((()()))
(()())())
())(()))()
(())(())))
impossible
()))(())((
()((())())
()))()))()
()((())())
()()))((()
()))(()))
(()(())))
())((()))
())()((())
(()(())))
impossible
))))())))(
impossible
impossible
...

result:

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