QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#645865 | #7683. Hard Brackets Problem | E_REMAL | WA | 56ms | 3676kb | C++14 | 595b | 2024-10-16 20:11:56 | 2024-10-16 20:11:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,l,r;
string s;
vector <int> ans;
bool b;
int main()
{
cin>>n;
while(n--) {
cin>>s;
l=0;
r=s.length()-1;
b=1;
ans.clear();
while(l<=r) {
if(s[r]=='(') {
b=0;
break;
}
if(s[l]=='(' && s[r]==')' ) {
ans.push_back(0);
l++;
r--;
}
else if(s[l]==')') {
ans.push_back(1);
l++;
}
}
if(b==0) cout<<"impossible"<<endl;
else {
for(int i=0;i<ans.size();i++) {
if(ans[i]==0) cout<<'(';
else cout<<')';
}
cout<<endl;
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3676kb
input:
3 ((())) ( )))()
output:
((( impossible )))(
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 56ms
memory: 3616kb
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 impos...
result:
wrong answer the result string is incorrect (test case 2)