Artifact Content
Not logged in

Artifact 41eb9ab0d33a154bbc6b42872a9b3151f146806e


#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 OrderedNim { public:
	string winner(vector <int> layout) 
	{
		bool firstWin = false;
		for(int i=layout.size()-1; i>=0; --i)
			if( layout[i] == 1 )
				firstWin = !firstWin;
			else
				firstWin = true;
		return firstWin ? "Alice" : "Bob";
	}
};

// 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(_, OrderedNim().winner(layout));}
int main(){

CASE(0)
	int layout_[] = {5};
	  vector <int> layout(layout_, layout_+sizeof(layout_)/sizeof(*layout_)); 
	string _ = "Alice"; 
END
CASE(1)
	int layout_[] = {1,2};
	  vector <int> layout(layout_, layout_+sizeof(layout_)/sizeof(*layout_)); 
	string _ = "Bob"; 
END
CASE(2)
	int layout_[] = {2,1};
	  vector <int> layout(layout_, layout_+sizeof(layout_)/sizeof(*layout_)); 
	string _ = "Alice"; 
END
CASE(3)
	int layout_[] = {10,9,8,7,6,5,4,3,2,1};
	  vector <int> layout(layout_, layout_+sizeof(layout_)/sizeof(*layout_)); 
	string _ = "Alice"; 
END
CASE(4)
	int layout_[] = {1,1,1,1};
	  vector <int> layout(layout_, layout_+sizeof(layout_)/sizeof(*layout_)); 
	string _ = "Bob"; 
END
CASE(5)
	int layout_[] = {1};
	  vector <int> layout(layout_, layout_+sizeof(layout_)/sizeof(*layout_)); 
	string _ = "Alice"; 
END
CASE(6)
	int layout_[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
	  vector <int> layout(layout_, layout_+sizeof(layout_)/sizeof(*layout_)); 
	string _ = "Bob"; 
END

}
// END CUT HERE