QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#275819 | #7683. Hard Brackets Problem | ship2077 | WA | 10ms | 3836kb | C++14 | 407b | 2023-12-05 08:41:26 | 2023-12-05 08:41:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int M=1e6+5;bool fl;
char s[M],t[M];int n,m,T;
int main(){
scanf("%d",&T);
while (T--){ fl=m=0;
scanf("%s",s+1);n=strlen(s+1);
for (int i=1;i<=n;i++)
if (s[i]==')') t[++m]=')';
else if (s[n]==')')
t[++m]='(',n--;
else {fl=1;break;}
if (fl) puts("impossible");
else t[m+1]='\0',printf("%s\n",t+1);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3780kb
input:
3 ((())) ( )))()
output:
((( impossible )))(
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 3836kb
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)