xiezongxi2 @ 2024-12-22 10:47:11
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
//#pragma GCC optimize(2)//O2优化
//#pragma GCC optimize(3)//O3优化
//f6停止程序
#define LL long long
using namespace std;
const int N=1e5+10;
const int Inf=0x3f3f3f3f;
string c,d;
stack<char> a,b;
stack<int> xi,zh;
int main(){
// freopen("xxx.in","r",stdin);
// freopen("xxx.out","w",stdout);
cin>>c;
d=c;
for(int i=c.size()-1;i>=0;i--){
if(c[i]==')'){
a.push(')');
}
if(c[i]=='('){
if(a.empty()){
// if(a.top()!=')')d.insert(i+2,"[");
d.insert(i+1,")");
}else a.pop();
}
if(c[i]==']')a.push(']');
if(c[i]=='['){
if(a.empty()){
// if(a.top()!=']')d.insert(i+2,"(");
d.insert(i+1,"]");
}else a.pop();
}
}cout<<d;
return 0;
}