Artifact Content
Not logged in

Artifact 5862d1075889b63db0d9a85c709db1900dbf450b


#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>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef complex<LD> CMP;

class CheckerExpansion { public:
	vector <string> resultAfter(long long t, long long x0, long long y0, int w, int h)
	{
		vector<string> answer(h, string(w, '.'));
		for(int y_=0; y_<h; ++y_)
		for(int x_=0; x_<w; ++x_) {
			LL y = y0 + y_;
			LL x = x0 + x_;
			if( (y+x)%2==1 )
				continue;
			LL N = (y+x)/2;
			if( t <= N )
				continue;
			LL k = x-N;
			if( k<0 || N<k )
				continue;
			if( is_comb_odd(N,k) )
				answer[h-y_-1][x_] = (N%2==0 ? 'A' : 'B');
		}
		return answer;
	}

	bool is_comb_odd(LL n, LL k)
	{
		for(LL m=1; m<=n; m<<=1)
			if( (k&m) && !(n&m) )
				return false;
		return true;
	}
};

// 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 vector <string>& Expected, const vector <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(_, CheckerExpansion().resultAfter(t, x0, y0, w, h));}
int main(){

CASE(0)
	long long t = 1LL; 
	long long x0 = 0LL; 
	long long y0 = 0LL; 
	int w = 4; 
	int h = 4; 
	string __[] = {"....", "....", "....", "A..." };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(1)
	long long t = 5LL; 
	long long x0 = 4LL; 
	long long y0 = 1LL; 
	int w = 3; 
	int h = 4; 
	string __[] = {"A..", "...", "B..", ".B." };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(2)
	long long t = 1024LL; 
	long long x0 = 1525LL; 
	long long y0 = 512LL; 
	int w = 20; 
	int h = 2; 
	string __[] = {"B...B...B...........", ".B.A.B.A.B.........." };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(3)
	long long t = 53LL; 
	long long x0 = 85LL; 
	long long y0 = 6LL; 
	int w = 5; 
	int h = 14; 
	string __[] = {".....", ".....", "B....", ".B.A.", ".....", ".....", ".....", ".....", ".....", ".....", "B....", ".B...", "..B..", ".A.B." };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(4)
	long long t = 1000000000000LL; 
	long long x0 = 1000000000000LL; 
	long long y0 =  123456789123LL; 
	int w = 50; 
	int h = 50; 
	string __[] = {"?"};
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
/*
CASE(5)
	long long t = LL; 
	long long x0 = LL; 
	long long y0 = LL; 
	int w = ; 
	int h = ; 
	string __[] = ;
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
*/
}
// END CUT HERE