Artifact 3a5fb18ce90cdda643aece911bff49d917ca34ac
#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 <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class TripleStrings { public:
int getMinimumOperations(string init, string goal)
{
for(int i=0; i<=init.size(); ++i)
if( init.substr(i, init.size()-i) == goal.substr(0, init.size()-i) )
return 2*i;
assert(false);
return -1;
}
};
// 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(_, TripleStrings().getMinimumOperations(init, goal));}
int main(){
CASE(0)
string init = "ooxxox";
string goal = "xoxoxo";
int _ = 6;
END
CASE(1)
string init = "oooxxoo";
string goal = "oooxxoo";
int _ = 0;
END
CASE(2)
string init = "ox";
string goal = "xo";
int _ = 2;
END
CASE(3)
string init = "ooxxooxx";
string goal = "xxoxoxoo";
int _ = 12;
END
CASE(4)
string init = "oxxoxxoooxooooxxxoo";
string goal = "oxooooxxxooooxoxxxo";
int _ = 16;
END
CASE(5)
string init = "xxxoxoxxooxooxoxooo";
string goal = "oxxooxxooxxoxoxooxo";
int _ = 36;
END
CASE(6)
string init = "oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox";
string goal = "oooooooooooooooooooooooooxxxxxxxxxxxxxxxxxxxxxxxxx";
int _ = -1;
END
CASE(7)
string init = "o";
string goal = "o";
int _ = 0;
END
CASE(8)
string init = "ox";
string goal = "xo";
int _ = 2;
END
}
// END CUT HERE