QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#738214 | #7683. Hard Brackets Problem | qikala7777 | WA | 11ms | 3568kb | C++23 | 1.1kb | 2024-11-12 18:16:33 | 2024-11-12 18:16:33 |
Judging History
answer
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef tuple<int,LL,LL> TPL;
typedef pair<LL,LL> PII;
const int N=1e6+7,inf=0x3f3f3f3f;const LL Linf=0x3f3f3f3f3f3f3f3fLL;
LL qsm(LL a,LL b,LL p){LL res=1;while(b){if(b&1)res=res*a%p;a=a*a%p;b>>=1;}return res;}
LL lowbit(LL x){return x&-x;}
string s;
void solve(){
cin>>s;
int n=s.size();
s="$"+s;
int rr=0;
string ans;
bool f=1;
for(int i=1;i<=n;i++){
if(s[i]=='('){
if(!f){
cout<<"impossible"<<endl;
return;
}
ans+='(';
rr++;
}else{
if(rr){
rr--;
f=0;
}else{
ans+=')';
f=1;
}
}
}
if(rr){
cout<<"impossible"<<endl;
}else{
cout<<ans<<endl;
}
}
int main(){
IOS
int T=1;
cin>>T;
while(T--)solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3500kb
input:
3 ((())) ( )))()
output:
((( impossible )))(
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 11ms
memory: 3568kb
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 impossible...
result:
wrong answer Jury has the answer but participant has not (test case 2)