QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#696672 | #7683. Hard Brackets Problem | Regina# | WA | 0ms | 3600kb | C++14 | 887b | 2024-11-01 00:21:51 | 2024-11-01 00:21:52 |
Judging History
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;
}
详细
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)