#include <bits/stdc++.h>
#include <ext/numeric>
//#include <ext/hash_map>
using namespace std;
using namespace __gnu_cxx;
#define oo 1e9
#define OO 1e18
#define EPS 1e-7
#define f first
#define s second
#define ll long long
#define pi acos(-1.0)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define popCnt(x) __builtin_popcount(x)
int dp[ 55 ] [ 55 ] ;
string str;
int getCost( int i,int j) {
if ( str[ i] == '(' && str[ j] == '(' ) return 1 ;
if ( str[ i] == '(' && str[ j] == ')' ) return 0 ;
if ( str[ i] == ')' && str[ j] == '(' ) return 2 ;
if ( str[ i] == ')' && str[ j] == ')' ) return 1 ;
return 0 ;
}
int solve( int i,int j) {
if ( j<= i) return ( i== j? oo: 0 ) ;
int & ret= dp[ i] [ j] ;
if ( ~ret) return ret;
ret= solve( i+ 1 ,j- 1 ) + getCost( i,j) ;
for ( int k= i; k<= j; k++ )
ret= min( ret,solve( i,k) + solve( k+ 1 ,j) ) ;
return ret;
}
vector< int > ans;
void getAns( int i,int j) {
if ( j<= i) return ;
int ch= solve( i+ 1 ,j- 1 ) + getCost( i,j) ;
for ( int k= i; k<= j; k++ )
ch= min( ch,solve( i,k) + solve( k+ 1 ,j) ) ;
if ( solve( i+ 1 ,j- 1 ) + getCost( i,j) == ch) {
if ( str[ i] ! = '(' ) ans.push_back ( i) ;
if ( str[ j] ! = ')' ) ans.push_back ( j) ;
getAns( i+ 1 ,j- 1 ) ;
}
else
for ( int k= i; k<= j; k++ ) {
if ( solve( i,k) + solve( k+ 1 ,j) == ch) {
getAns( i,k) ;
getAns( k+ 1 ,j) ;
break ;
}
}
}
class ParenthesesDiv2Medium{
public :
vector < int > correct( string s) {
str= s;
memset ( dp,- 1 ,sizeof dp) ;
solve( 0 ,sz( s) - 1 ) ;
getAns( 0 ,sz( s) - 1 ) ;
sort( all( ans) ) ;
return ans;
}
} ;
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlI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