QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#656646 | #7683. Hard Brackets Problem | test_algth | WA | 19ms | 3628kb | C++14 | 740b | 2024-10-19 13:29:30 | 2024-10-19 13:29:30 |
Judging History
answer
#include <bits/stdc++.h>
const int MAXN = 1.01E6;
char A[MAXN];
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int testCase = 1;
std::cin >> testCase;
while (testCase--) {
std::cin >> A;
bool ok = true;
std::vector <char> Ans;
int now = 0, N = strlen(A);
for (int i = 0; i < N; ++i) {
char a = A[i];
if (a == '(')
Ans.push_back('('), ++now;
else {
if (!now) Ans.push_back(')');
else --now;
}
}
if (now == 0) {
for (char a : Ans)
std::cout << a;
std::cout << '\n';
} else {
std::cout << "impossible" << '\n';
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
input:
3 ((())) ( )))()
output:
((( impossible )))(
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 19ms
memory: 3628kb
input:
100000 ())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) )))))(((() ()))((()(( ()((()())) (()())()) ())(()))() (())(()))) ))))(()(() ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) ()(((()()) ))))())))( ((((()()() (()(...
output:
impossible (()()) )(((( impossible (((() impossible )())())) impossible impossible ((((( (((() ()(()( (((()) impossible impossible ((((( ())())( ((((( impossible ())(() (((() ()((( impossible (((() impossible impossible impossible impossible impossible ()(()( impossible impossible impossible )))(()(...
result:
wrong answer the result string is incorrect (test case 2)