Artifact Content
Not logged in

Artifact 295e562b1438d93f1402574dcb860cd99577d9eb


#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 StonesGame { public:
	string winner(int N, int M, int K, int L) 
	{
		if( isOneStep(N,M,K,L) ) // M から L に一手でいけるなら先手の勝ち
			return "Romeo";
		for(int x=1; x<=N; ++x)
			if( isOneStep(N,M,K,x) && !isOneStep(N,x,K,L) )
				return "Draw"; // 先手も後手も勝てない場合
		return "Strangelet"; // M からは「Lに一手で行けちゃうx」にしか行けないなら、後手の勝ち
	}

	bool isOneStep(int N, int M, int K, int L)
	{
		int d = abs(M-L);
		if( d<K && (d%2)!=(K%2) )
		{
			int mid = (M+L)/2; // M と L の真ん中を中心に
			int e = mid + K/2; // 右に K/2
			int b = e - K+1;   // 左に K/2 伸ばした範囲をreverseすればMがLに行けるはず…
			return 1<=b && e<=N; // そんな範囲で大丈夫か
		}
		return false;
	}
};

// 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(_, StonesGame().winner(N, M, K, L));}
int main(){

CASE(0)
	int N = 3; 
	int M = 1; 
	int K = 1; 
	int L = 2; 
	string _ = "Draw"; 
END
CASE(1)
	int N = 5; 
	int M = 1; 
	int K = 2; 
	int L = 2; 
	string _ = "Romeo"; 
END
CASE(2)
	int N = 5; 
	int M = 5; 
	int K = 2; 
	int L = 3; 
	string _ = "Strangelet"; 
END
CASE(3)
	int N = 5; 
	int M = 5; 
	int K = 2; 
	int L = 2; 
	string _ = "Draw"; 
END
CASE(4)
	int N = 1000000; 
	int M = 804588; 
	int K = 705444; 
	int L = 292263; 
	string _ = "Romeo"; 
END
CASE(5)
	int N = 1000000; 
	int M = 100000; 
	int K = 500000; 
	int L = 600000; 
	string _ = "Strangelet"; 
END
CASE(6)
	int N = 5; 
	int M = 1; 
	int K = 3; 
	int L = 5; 
	string _ = "Strangelet"; 
END
/*
CASE(7)
	int N = ; 
	int M = ; 
	int K = ; 
	int L = ; 
	string _ = ; 
END
*/
}
// END CUT HERE