Artifact Content
Not logged in

Artifact 762d28b66486ec7df90aacc5077395d1ec0094c2


#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;

static const int MODVAL = 1000000009; // op/ depends on primarity of the MODVAL
struct mint
{
	int val;
	mint():val(0){}
	mint(int x):val(x%MODVAL) {}
	mint(LL  x):val(x%MODVAL) {}
};

mint operator+(mint x, mint y) { return x.val+y.val; }
mint operator-(mint x, mint y) { return x.val-y.val+MODVAL; }
mint operator*(mint x, mint y) { return LL(x.val)*y.val; }
mint POW(mint x, int e) {
	mint v = 1;
	for(;e;x=x*x,e>>=1)
		if(e&1)
			v=v*x;
	return v;
}
mint operator/(mint x, mint y) { return x * POW(y, MODVAL-2); }

vector<mint> FAC_(1,1);
void FAC_INIT(int n) { for(int i=1; i<=n; ++i) FAC_.push_back( FAC_.back()*i ); }
mint FAC(mint x)       { return FAC_[x.val]; }
mint C(mint n, mint k) { return k.val<0 || n.val<k.val ? 0 : FAC(n) / (FAC(k) * FAC(n-k)); }

class FoxStones { public:
	int getCount(int W, int H, vector <int> sx, vector <int> sy) 
	{
		if(FAC_.size()==1)
			FAC_INIT(200*200+1);

		map<vector<int>,int> dd;
		for(int y=0; y<H; ++y)
			for(int x=0; x<W; ++x)
			{
				vector<int> dis;
				for(int i=0; i<sx.size(); ++i)
				{
					int d = max(abs(sy[i]-1-y), abs(sx[i]-1-x));
					dis.push_back(d);
				}
				dd[dis]++;
			}
		mint ans = 1;
		for(map<vector<int>,int>::iterator it=dd.begin(); it!=dd.end(); ++it)
		{
			int n = it->second;
			ans = ans * FAC(n);
		}
		return ans.val;
	}
};

// 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(_, FoxStones().getCount(N, M, sx, sy));}
int main(){

CASE(0)
	int N = 6; 
	int M = 1; 
	int sx_[] = {3};
	  vector <int> sx(sx_, sx_+sizeof(sx_)/sizeof(*sx_)); 
	int sy_[] = {1};
	  vector <int> sy(sy_, sy_+sizeof(sy_)/sizeof(*sy_)); 
	int _ = 4; 
END
CASE(1)
	int N = 2; 
	int M = 2; 
	int sx_[] = {2};
	  vector <int> sx(sx_, sx_+sizeof(sx_)/sizeof(*sx_)); 
	int sy_[] = {1};
	  vector <int> sy(sy_, sy_+sizeof(sy_)/sizeof(*sy_)); 
	int _ = 6; 
END
CASE(2)
	int N = 3; 
	int M = 3; 
	int sx_[] = {1,2,3};
	  vector <int> sx(sx_, sx_+sizeof(sx_)/sizeof(*sx_)); 
	int sy_[] = {1,2,3};
	  vector <int> sy(sy_, sy_+sizeof(sy_)/sizeof(*sy_)); 
	int _ = 8; 
END
CASE(3)
	int N = 12; 
	int M = 34; 
	int sx_[] = {5,6,7,8,9,10};
	  vector <int> sx(sx_, sx_+sizeof(sx_)/sizeof(*sx_)); 
	int sy_[] = {11,12,13,14,15,16};
	  vector <int> sy(sy_, sy_+sizeof(sy_)/sizeof(*sy_)); 
	int _ = 410850247; 
END
/*
CASE(4)
	int N = ; 
	int M = ; 
	int sx_[] = ;
	  vector <int> sx(sx_, sx_+sizeof(sx_)/sizeof(*sx_)); 
	int sy_[] = ;
	  vector <int> sy(sy_, sy_+sizeof(sy_)/sizeof(*sy_)); 
	int _ = ; 
END
CASE(5)
	int N = ; 
	int M = ; 
	int sx_[] = ;
	  vector <int> sx(sx_, sx_+sizeof(sx_)/sizeof(*sx_)); 
	int sy_[] = ;
	  vector <int> sy(sy_, sy_+sizeof(sy_)/sizeof(*sy_)); 
	int _ = ; 
END
*/
}
// END CUT HERE