QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#544213 | #7683. Hard Brackets Problem | ucup-team2179# | WA | 5ms | 3604kb | C++20 | 882b | 2024-09-02 12:31:03 | 2024-09-02 12:31:04 |
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;
}
}
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;
}
详细
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: 5ms
memory: 3604kb
input:
100000 ())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) )))))(((() ()))((()(( ()((()())) (()())()) ())(()))() (())(()))) ))))(()(() ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) ()(((()()) ))))())))( ((((()()() (()(...
output:
impossible impossible )()()()() impossible impossible impossible impossible impossible impossible ()((()())) impossible impossible impossible impossible impossible ()((())()) impossible ()((())()) impossible impossible impossible impossible impossible impossible impossible impossible impossible impo...
result:
wrong answer Jury has the answer but participant has not (test case 2)