- 小委出发
- 2015-12-01 14:52:32 @
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
string str;
cin >> str;
vector<int> vec;
vec.push_back('#');
for(unsigned int i = 0; i < str.size(); ++i){
if(str[i] != 40)
vec.push_back(str[i]);
else
vec.push_back(39);
if(str[i] == '}' || str[i] == ']' || str[i] == ')'){
if(vec.back() - 2 == (vec.end() - 2)){
vec.pop_back();
vec.pop_back();
if(vec.back() % 2 == 0 )
vec.back() += 2;
else
vec.push_back(2);
}else if((vec.end() - 2) % 2 == 0 && vec.back() - 2 == *(vec.end()-3)){
vec.pop_back();
int a = vec.back();
vec.pop_back();
vec.pop_back();
vec.push_back(a + 2);
}
}
}
int max = 0;
int max_i = 0;
for(unsigned int i = 1; i < vec.size(); i++){
if(vec[i] % 2 == 0)
if(vec[i] > max)
max = vec[i];
}
for(unsigned int i = 1; i < vec.size(); i++){
if(vec[i] == max){
max_i += max;
break;
}
if(vec[i] % 2 == 0)
max_i += vec[i];
else
max_i++;
}
for(int i = max_i - max; i < max_i; i++)
cout << str[i];
return 0;
}