QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#696672#7683. Hard Brackets ProblemRegina#WA 0ms3600kbC++14887b2024-11-01 00:21:512024-11-01 00:21:52

Judging History

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

  • [2024-11-01 00:21:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-11-01 00:21:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
string s;int t,n,sum;
inline int read(){
    int r=0,f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar();
    return r*f;
}
inline string sread(){
    string s=" ";char c=getchar();
    while(c!='('&&c!=')')c=getchar();
    while(c=='('||c==')')s+=c,c=getchar();
    return s;
}
void put(int x){
    if(x<0){putchar('-');x=~x+1;}
    if(x>9)put(x/10);
    putchar(x%10+'0');
}
signed main(){
//    freopen("cpp.in","r",stdin);
//    freopen("cpp.out","w",stdout);
    t=read();
    while(t--){
        s=sread(),n=s.size()-1,sum=0;
        for(int i=1;i<=n;i++){
            if(s[i]=='(')sum++;
            else sum=max(sum-1,0);
        }
        if(sum){puts("impossible");continue;}
        cout<<s<<endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3600kb

input:

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

output:

 ((()))
impossible
 )))()

result:

wrong answer the output is too long (test case 1)