QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#466758 | #7683. Hard Brackets Problem | yurongyi# | WA | 12ms | 3644kb | C++14 | 640b | 2024-07-08 09:29:50 | 2024-07-08 09:29:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
string s, ans;
int cnt1 = 0, cnt2 = 0;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int Cases;
cin >> Cases;
while(Cases--){
cin >> s;
ans.clear();
cnt1 = cnt2 = 0;
for(auto c : s){
if(c == '('){
while(cnt2){
ans.push_back(')');
cnt2--;
}
cnt1++;
}
else{
if(cnt1){
ans.push_back('(');
cnt1--, cnt2++;
}
else
ans.push_back(')');
}
// cout << cnt1 << endl;
}
if(cnt1)
cout << "impossible\n";
else
cout << ans << "\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
input:
3 ((())) ( )))()
output:
((( impossible )))(
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 12ms
memory: 3620kb
input:
100000 ())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) )))))(((() ()))((()(( ()((()())) (()())()) ())(()))() (())(()))) ))))(()(() ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) ()(((()()) ))))())))( ((((()()() (()(...
output:
impossible ()())()) )()()()( impossible (())(() impossible )()))())) impossible impossible ()()((( ()(())() ())(()))( (())(()) impossible impossible ()(())(( ()))()))( ()(())(( impossible ()))(() ()((() ())((( impossible ()((() impossible impossible impossible impossible impossible ())(()))( impossi...
result:
wrong answer the result string is incorrect (test case 2)