QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#544213#7683. Hard Brackets Problemucup-team2179#WA 5ms3604kbC++20882b2024-09-02 12:31:032024-09-02 12:31:04

Judging History

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

  • [2024-09-02 12:31:04]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3604kb
  • [2024-09-02 12:31:03]
  • 提交

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;
            }
        }
        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;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 5ms
memory: 3604kb

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
impo...

result:

wrong answer Jury has the answer but participant has not (test case 2)