QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#725721#7683. Hard Brackets Problemrqoi031WA 0ms1412kbC++20398b2024-11-08 19:35:442024-11-08 19:35:44

Judging History

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

  • [2024-11-08 19:35:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1412kb
  • [2024-11-08 19:35:44]
  • 提交

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;
}

详细

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)