2020-12-04 00:57:24 +00:00
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
char b[105];
|
|
|
|
int n;
|
|
|
|
string s;
|
|
|
|
stack<int> st;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
cin >> s;
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
if (s[i] == '(') {
|
|
|
|
st.push(i);
|
|
|
|
b[i] = ')';
|
|
|
|
}
|
|
|
|
if (s[i] == '[') {
|
|
|
|
st.push(i);
|
|
|
|
b[i] = ']';
|
|
|
|
}
|
|
|
|
if (s[i] == ')' || s[i] == ']') {
|
|
|
|
if (st.empty() || b[st.top()] != s[i]) {
|
|
|
|
if (s[i] == ')') {
|
|
|
|
b[i] = '(';
|
2021-11-19 09:01:13 +00:00
|
|
|
} else {
|
2020-12-04 00:57:24 +00:00
|
|
|
b[i] = '[';
|
|
|
|
}
|
2021-11-19 09:01:13 +00:00
|
|
|
} else {
|
2020-12-04 00:57:24 +00:00
|
|
|
b[st.top()] = ' ';
|
|
|
|
st.pop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
if (b[i] == '(' || b[i] == '[') {
|
|
|
|
cout << b[i];
|
|
|
|
}
|
|
|
|
cout << s[i];
|
|
|
|
if (b[i] == ')' || b[i] == ']') {
|
|
|
|
cout << b[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cout << endl;
|
|
|
|
return 0;
|
|
|
|
}
|