Artifact a37ca3e9fed3b6d24dc5f4fdc6e66e6b5b8d2a23
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class ParenthesesDiv1Easy { public:
vector <int> correct(string s)
{
if(s.length()%2 == 1)
return vector<int>(1, -1);
vector<int> ans;
int d = 0;
int peak = 0, peak_i = -1;
for(int i=0; i<s.size(); ++i) {
if(d == 0 && s[i]==')') {
int sec_s = i;
int sec_d = -1;
int bot=-1, bot_k=i;
for(int k=sec_s+1; sec_d<0 && k<s.size(); ++k) {
sec_d += (s[k]=='(' ? +1 : -1);
if(bot>sec_d) { bot=sec_d, bot_k=k; }
}
ans.push_back(sec_s);
ans.push_back(bot_k);
reverse(s.begin()+sec_s, s.begin()+bot_k+1);
for(auto it=s.begin()+sec_s; it!=s.begin()+bot_k+1; ++it)
*it=(*it=='(' ? ')' : '(');
--i;
} else {
d += (s[i]=='(' ? +1 : -1);
if(peak<d) { peak=d; peak_i=i; }
}
}
int back = d/2;
if(back) {
int p=peak_i, d=peak;
for(;; --p) {
d -= (s[p]=='(' ? +1 : -1);
if(d==peak-back) {
ans.push_back(p);
ans.push_back(peak_i);
break;
}
}
}
return ans.size()>10 ? vector<int>(1, -1) : ans;
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const vector <int>& Expected, const vector <int>& Received) {
bool ok = (Expected == Received);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: " << Expected << endl << "\tx: " << Received << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, ParenthesesDiv1Easy().correct(s));}
int main(){
CASE(0)
string s = ")(";
int __[] = {0, 0, 1, 1 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(1)
string s = "))))))((((((";
int __[] = {0, 5, 6, 11 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(2)
string s = "))()())()";
int __[] = {-1 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(3)
string s = ")()(((";
int __[] = {0, 0, 3, 3, 5, 5 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(4)
string s = "()";
vector <int> _;
END
CASE(5)
string s = "))))()))(((()()((()()))))(())))(()()))))))())))))()()(()()(()))())((()))()((())))()())((()())(()(())))())()(()(()(()))))())))((()((())((()())(()())(()))((()()(()(()))((((((((((())((((()())()(()()())()(((((((()()())(()))(()())))))())((((())()(())(((()((()(())))(()((()())(((((()(()())(((()))()))(((()()()))()())))(())(())(()))))())(()))))()(()(()())(()())((()))()()((())(((()(((()(()()((())())())((()))))())((((())(()()()())(((((())(((())))))())()))()())())))(()()())((((()()))))())())())()())((()))(()(()))()(())))(()))()))(())((()())())())((((())))(()())())))(()((())()()())()))()))())(())((((()()((()(()())()(((()))))(()()()))())))(()())(())())(()))()())((()))((())))()((())(()))))))()(()(((()())(())(()((()((((())))((())))))()))()(()())()())))())(())))((()))()))(()()))())(()(())((()(()))((((()()())())(()))(((())()()))(((()(()()(()())()))(()()())())))(()())(()((()()(())()()((()()()())()))())((((((()((()()(((()(()(()(())(((((((((()(())((())))(())())((())()()(((()))()()(((((((())(())))))))(())()";
int __[] = {-2};
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
/*
CASE(6)
string s = ;
int __[] = ;
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
*/
}
// END CUT HERE