QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#395391 | #7683. Hard Brackets Problem | zzuqy# | WA | 13ms | 3872kb | C++14 | 573b | 2024-04-21 14:03:42 | 2024-04-21 14:03:43 |
Judging History
answer
#include <bits/stdc++.h>
char s[1000006], ans[1000006];
int main() {
int t;
scanf("%d", &t);
while (t--) {
scanf("%s", s);
int n = std::strlen(s), l = 0;
for (int i = 0; i < n; i++) {
if (s[i] == ')') {
ans[++l] = ')';
continue;
}
int o = 0;
while (i < n && s[i] == '(')
o++, i++, ans[++l] = '(';
while (i < n && o > 0 && s[i] == ')')
o--, i++, ans[++l] = ')';
i--;
if (o > 0)
goto FAIL;
}
ans[++l] = 0;
printf("%s\n", ans + 1);
continue;
FAIL:
puts("impossible");
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
3 ((())) ( )))()
output:
((())) impossible )))()
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 13ms
memory: 3872kb
input:
100000 ())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) )))))(((() ()))((()(( ()((()())) (()())()) ())(()))() (())(()))) ))))(()(() ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) ()(((()()) ))))())))( ((((()()() (()(...
output:
impossible ()())())) )()()()() impossible impossible impossible )()))()))) impossible impossible impossible impossible ())(()))() (())(()))) impossible impossible impossible ()))()))() impossible impossible ()))(())) impossible ())((())) impossible impossible impossible impossible impossible impossi...
result:
wrong answer Jury has the answer but participant has not (test case 5)