Artifact 672e9b49bba83305f8f9c72918e0a2eb9c594760
#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 MagicalStringDiv1 { public:
int getLongest(string S)
{
int best = 0;
for(int rBegin=0; rBegin<S.size(); ++rBegin)
{
int l = count(S.begin(), S.begin()+rBegin, '>');
int r = count(S.begin()+rBegin, S.end(), '<');
best = max(best, 2*min(l,r));
}
return best;
}
};
// 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 int& Expected, const 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(_, MagicalStringDiv1().getLongest(S));}
int main(){
CASE(0)
string S = "<><><<>";
int _ = 4;
END
CASE(1)
string S = ">>><<<";
int _ = 6;
END
CASE(2)
string S = "<<<>>>";
int _ = 0;
END
CASE(3)
string S = "<<<<><>>><>>><>><>><>>><<<<>><>>>>><<>>>>><><<<<>>";
int _ = 24;
END
/*
CASE(4)
string S = ;
int _ = ;
END
CASE(5)
string S = ;
int _ = ;
END
*/
}
// END CUT HERE