QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#725721 | #7683. Hard Brackets Problem | rqoi031 | WA | 0ms | 1412kb | C++20 | 398b | 2024-11-08 19:35:44 | 2024-11-08 19:35:44 |
Judging History
answer
#include<stdio.h>
#include<algorithm>
#include<cstring>
char str[1000005];
inline void solve() {
scanf("%s",str);
const int n(std::strlen(str));
int s(0);
for(int i=0;i!=n;i++) {
s=std::max(0,s+(str[i]=='('?1:-1));
}
puts(s>0?"Impossible":str);
}
int main() {
int t;
scanf("%d",&t);
while(t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1412kb
input:
3 ((())) ( )))()
output:
((())) Impossible )))()
result:
wrong answer the output is too long (test case 2)