QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#463405#7683. Hard Brackets Problemucup-team1113WA 4ms3848kbC++17727b2024-07-04 20:03:332024-07-04 20:03:34

Judging History

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

  • [2024-07-04 20:03:34]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3848kb
  • [2024-07-04 20:03:33]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long double db;
typedef long long ll;

const ll N = 2e5 + 10;
const ll mod = 998244353;
const ll inf32 = 0x3f3f3f3f;
const ll inf64 = 5e18;

void solve(){
    string s;
    cin >> s;
    int n = s.size();
    if (s[n - 1] == '(') {
        cout << "impossible" << endl;
        return;
    }
    int pos = n - 1;
    for (int i = n - 1; i >= 0; --i){
        if (s[i] == '(') {
            pos = i + 1;
            break;
        }
    }
    cout << s.substr(0, pos) << endl;
}

signed main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t = 1;
    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: 3576kb

input:

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

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3848kb

input:

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

output:

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

result:

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