QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#647514 | #7683. Hard Brackets Problem | KOH-# | WA | 10ms | 3720kb | C++14 | 532b | 2024-10-17 14:32:12 | 2024-10-17 14:32:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
char a[N],b[N];
int n,m;
void solve(){
scanf("%s",a+1);
n=strlen(a+1);
m=0;
for(int i=1;i<=n;i++){
if(a[i]==')'){
m++;
b[m]=')';
}
else{
if(n<=i){
puts("impossible");
return ;
}
if(a[n]==')'){
n--;
m++;
b[m]='(';
}
else{
puts("impossible");
return ;
}
}
}
for(int i=1;i<=m;i++) putchar(b[i]);
puts("");
}
int main(){
int T;
scanf("%d",&T);
while(T--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3664kb
input:
3 ((())) ( )))()
output:
((( impossible )))(
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 3720kb
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)