QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#800600 | #7683. Hard Brackets Problem | UESTC_DebugSimulator# | WA | 8ms | 3644kb | C++17 | 475b | 2024-12-06 13:16:30 | 2024-12-06 13:16:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
string work(){
string s;
cin>>s;
int fl=0,nw=0;
string ans;
for(auto c:s){
if(c=='('){
while(nw){
ans+=')';
nw--;
}
fl++;
ans+='(';
}
else{
if(fl==0)ans+=')';
else{
fl--;
nw++;
}
}
}
if(fl>0)return "impossible";
return ans;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin>>T;
while(T--)cout<<work()<<"\n";
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: 8ms
memory: 3644kb
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)