QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#463405 | #7683. Hard Brackets Problem | ucup-team1113 | WA | 4ms | 3848kb | C++17 | 727b | 2024-07-04 20:03:33 | 2024-07-04 20:03:34 |
Judging History
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)