Artifact Content
Not logged in

Artifact bb17ad1de92715161f676d98f6d5507a8dcd2ae3


#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 PatrolRoute { public:
	int countRoutes(int X, int Y, int minT, int maxT)
	{
		--X, --Y;

		LL count = 0;
		for(int W=2; W<=X; ++W)
			for(int H=2; H<=Y; ++H)
				if( minT <= (W+H)*2 && (W+H)*2 <= maxT )
					count = (count + threePoints(W,H) * (X-W+1)*(Y-H+1)) % 1000000007;
		return count;
	}

	LL threePoints(int W, int H)
	{
		LL a = (W-1)*(H-1);
		LL b = (W-1)*(H-1);
		return 4*a + 2*b;
	}
};

// 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(_, PatrolRoute().countRoutes(X, Y, minT, maxT));}
int main(){

CASE(0)
	int X = 3; 
	int Y = 3; 
	int minT = 1; 
	int maxT = 20000; 
	int _ = 6; 
END
CASE(1)
	int X = 3; 
	int Y = 3; 
	int minT = 4; 
	int maxT = 7; 
	int _ = 0; 
END
CASE(2)
	int X = 4; 
	int Y = 6; 
	int minT = 9; 
	int maxT = 12; 
	int _ = 264; 
END
CASE(3)
	int X = 7; 
	int Y = 5; 
	int minT = 13; 
	int maxT = 18; 
	int _ = 1212; 
END
CASE(4)
	int X = 4000; 
	int Y = 4000; 
	int minT = 4000; 
	int maxT = 14000; 
	int _ = 859690013; 
END
CASE(5)
	int X = 4000; 
	int Y = 4000; 
	int minT = 1; 
	int maxT = 20000; 
	int _ = -1; 
END
CASE(6)
	int X = 3; 
	int Y = 3; 
	int minT = 1; 
	int maxT = 1; 
	int _ = 0; 
END

}
// END CUT HERE