Artifact Content
Not logged in

Artifact 54bf3e40d837f13bc1b6081aee17938ec0fdd224


#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 SequenceOfCommands { public:
	string whatHappens(vector <string> commands) 
	{
		string cmd = accumulate(commands.begin(), commands.end(), string (""));
		cmd = cmd+cmd+cmd+cmd;

		int dx=1, dy=0;
		int px=0, py=0;
		for(int i=0; i<cmd.size(); ++i)
			if(cmd[i]=='S')
				{px+=dx, py+=dy;}
			else if(cmd[i]=='L')
				{int t=dx; dx=-dy; dy=t;}
			else if(cmd[i]=='R')
				{int t=dx; dx=dy; dy=-t;}
		return (px==0 && py==0 ? "bounded" : "unbounded");
	}
};

// 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 string& Expected, const string& 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(_, SequenceOfCommands().whatHappens(commands));}
int main(){

CASE(0)
	string commands_[] = {"L"};
	  vector <string> commands(commands_, commands_+sizeof(commands_)/sizeof(*commands_)); 
	string _ = "bounded"; 
END
CASE(1)
	string commands_[] = {"SRSL"};
	  vector <string> commands(commands_, commands_+sizeof(commands_)/sizeof(*commands_)); 
	string _ = "unbounded"; 
END
CASE(2)
	string commands_[] = {"SSSS","R"};
	  vector <string> commands(commands_, commands_+sizeof(commands_)/sizeof(*commands_)); 
	string _ = "bounded"; 
END
CASE(3)
	string commands_[] = {"SRSL","LLSSSSSSL","SSSSSS","L"};
	  vector <string> commands(commands_, commands_+sizeof(commands_)/sizeof(*commands_)); 
	string _ = "unbounded"; 
END
CASE(4)
	string commands_[] = {"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS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SSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL","SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSL"};
	  vector <string> commands(commands_, commands_+sizeof(commands_)/sizeof(*commands_)); 
	string _ = "bounded"; 
END
CASE(5)
	string commands_[] = {"R"};
	  vector <string> commands(commands_, commands_+sizeof(commands_)/sizeof(*commands_)); 
	string _ = "bounded"; 
END
CASE(6)
	string commands_[] = {"S"};
	  vector <string> commands(commands_, commands_+sizeof(commands_)/sizeof(*commands_)); 
	string _ = "unbounded"; 
END
CASE(7)
	string commands_[] = {"SRSLSRSL", "RR"};
	  vector <string> commands(commands_, commands_+sizeof(commands_)/sizeof(*commands_)); 
	string _ = "bounded"; 
END
}
// END CUT HERE