QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#544216 | #7683. Hard Brackets Problem | ucup-team2179# | WA | 3ms | 3532kb | C++20 | 772b | 2024-09-02 12:39:36 | 2024-09-02 12:39:37 |
Judging History
answer
#include<bits/stdc++.h>
// #define int long long
#define pii pair<int, int>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 998244353;
void solve() {
string str;
cin >> str;
int n = str.length();
for (int i = 0; i < n; i++) {
if (str[i] == ')') continue;
int sum = 0;
for (int j = i; j < n; j++) {
if (str[j] == '(')
sum++;
else
sum--;
}
if (sum > 0) {
cout << "impossible\n";
return;
}
break;
}
cout << str << "\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int t; cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
input:
3 ((())) ( )))()
output:
((())) impossible )))()
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3532kb
input:
100000 ())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) )))))(((() ()))((()(( ()((()())) (()())()) ())(()))() (())(()))) ))))(()(() ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) ()(((()()) ))))())))( ((((()()() (()(...
output:
())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) impossible impossible ()((()())) (()())()) ())(()))() (())(()))) impossible ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) impossible ))))())))( impossible impossible ...
result:
wrong answer the result string is incorrect (test case 1)