QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#276135 | #7683. Hard Brackets Problem | yujie3 | WA | 31ms | 3748kb | C++20 | 423b | 2023-12-05 16:55:06 | 2023-12-05 16:55:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n;
void solve(){
string s; cin >> s;
n = s.size();
int l = 0,r = n - 1;
while(l <= r){
if(s[l] == ')') l ++;
else {
if(s[l] == s[r]){
cout << "impossible" << endl;
return;
} l ++,r --;
}
} for(int i = 0;i < l;i ++) cout << s[i];
cout << endl;
}
signed main(){
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: 3592kb
input:
3 ((())) ( )))()
output:
((( impossible )))(
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 31ms
memory: 3748kb
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 impos...
result:
wrong answer the result string is incorrect (test case 2)