9f60383a2c 2012-06-16 kinaba: #include <iostream> 9f60383a2c 2012-06-16 kinaba: #include <sstream> 9f60383a2c 2012-06-16 kinaba: #include <iomanip> 9f60383a2c 2012-06-16 kinaba: #include <vector> 9f60383a2c 2012-06-16 kinaba: #include <string> 9f60383a2c 2012-06-16 kinaba: #include <map> 9f60383a2c 2012-06-16 kinaba: #include <set> 9f60383a2c 2012-06-16 kinaba: #include <algorithm> 9f60383a2c 2012-06-16 kinaba: #include <numeric> 9f60383a2c 2012-06-16 kinaba: #include <iterator> 9f60383a2c 2012-06-16 kinaba: #include <functional> 9f60383a2c 2012-06-16 kinaba: #include <complex> 9f60383a2c 2012-06-16 kinaba: #include <queue> 9f60383a2c 2012-06-16 kinaba: #include <stack> 9f60383a2c 2012-06-16 kinaba: #include <cmath> 9f60383a2c 2012-06-16 kinaba: #include <cassert> 9f60383a2c 2012-06-16 kinaba: using namespace std; 9f60383a2c 2012-06-16 kinaba: typedef long long LL; 9f60383a2c 2012-06-16 kinaba: typedef long double LD; 9f60383a2c 2012-06-16 kinaba: typedef complex<LD> CMP; 9f60383a2c 2012-06-16 kinaba: 9f60383a2c 2012-06-16 kinaba: class PatrolRoute { public: 9f60383a2c 2012-06-16 kinaba: int countRoutes(int X, int Y, int minT, int maxT) 9f60383a2c 2012-06-16 kinaba: { 9f60383a2c 2012-06-16 kinaba: --X, --Y; 9f60383a2c 2012-06-16 kinaba: 9f60383a2c 2012-06-16 kinaba: LL count = 0; 9f60383a2c 2012-06-16 kinaba: for(int W=2; W<=X; ++W) 9f60383a2c 2012-06-16 kinaba: for(int H=2; H<=Y; ++H) 9f60383a2c 2012-06-16 kinaba: if( minT <= (W+H)*2 && (W+H)*2 <= maxT ) 9f60383a2c 2012-06-16 kinaba: count = (count + threePoints(W,H) * (X-W+1)*(Y-H+1)) % 1000000007; 9f60383a2c 2012-06-16 kinaba: return count; 9f60383a2c 2012-06-16 kinaba: } 9f60383a2c 2012-06-16 kinaba: 9f60383a2c 2012-06-16 kinaba: LL threePoints(int W, int H) 9f60383a2c 2012-06-16 kinaba: { 9f60383a2c 2012-06-16 kinaba: LL a = (W-1)*(H-1); 9f60383a2c 2012-06-16 kinaba: LL b = (W-1)*(H-1); 9f60383a2c 2012-06-16 kinaba: return 4*a + 2*b; 9f60383a2c 2012-06-16 kinaba: } 9f60383a2c 2012-06-16 kinaba: }; 9f60383a2c 2012-06-16 kinaba: 9f60383a2c 2012-06-16 kinaba: // BEGIN CUT HERE 9f60383a2c 2012-06-16 kinaba: #include <ctime> 9f60383a2c 2012-06-16 kinaba: double start_time; string timer() 9f60383a2c 2012-06-16 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } 9f60383a2c 2012-06-16 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) 9f60383a2c 2012-06-16 kinaba: { os << "{ "; 9f60383a2c 2012-06-16 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) 9f60383a2c 2012-06-16 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } 9f60383a2c 2012-06-16 kinaba: void verify_case(const int& Expected, const int& Received) { 9f60383a2c 2012-06-16 kinaba: bool ok = (Expected == Received); 9f60383a2c 2012-06-16 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; 9f60383a2c 2012-06-16 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } 9f60383a2c 2012-06-16 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); 9f60383a2c 2012-06-16 kinaba: #define END verify_case(_, PatrolRoute().countRoutes(X, Y, minT, maxT));} 9f60383a2c 2012-06-16 kinaba: int main(){ 9f60383a2c 2012-06-16 kinaba: 9f60383a2c 2012-06-16 kinaba: CASE(0) 9f60383a2c 2012-06-16 kinaba: int X = 3; 9f60383a2c 2012-06-16 kinaba: int Y = 3; 9f60383a2c 2012-06-16 kinaba: int minT = 1; 9f60383a2c 2012-06-16 kinaba: int maxT = 20000; 9f60383a2c 2012-06-16 kinaba: int _ = 6; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(1) 9f60383a2c 2012-06-16 kinaba: int X = 3; 9f60383a2c 2012-06-16 kinaba: int Y = 3; 9f60383a2c 2012-06-16 kinaba: int minT = 4; 9f60383a2c 2012-06-16 kinaba: int maxT = 7; 9f60383a2c 2012-06-16 kinaba: int _ = 0; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(2) 9f60383a2c 2012-06-16 kinaba: int X = 4; 9f60383a2c 2012-06-16 kinaba: int Y = 6; 9f60383a2c 2012-06-16 kinaba: int minT = 9; 9f60383a2c 2012-06-16 kinaba: int maxT = 12; 9f60383a2c 2012-06-16 kinaba: int _ = 264; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(3) 9f60383a2c 2012-06-16 kinaba: int X = 7; 9f60383a2c 2012-06-16 kinaba: int Y = 5; 9f60383a2c 2012-06-16 kinaba: int minT = 13; 9f60383a2c 2012-06-16 kinaba: int maxT = 18; 9f60383a2c 2012-06-16 kinaba: int _ = 1212; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(4) 9f60383a2c 2012-06-16 kinaba: int X = 4000; 9f60383a2c 2012-06-16 kinaba: int Y = 4000; 9f60383a2c 2012-06-16 kinaba: int minT = 4000; 9f60383a2c 2012-06-16 kinaba: int maxT = 14000; 9f60383a2c 2012-06-16 kinaba: int _ = 859690013; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(5) 9f60383a2c 2012-06-16 kinaba: int X = 4000; 9f60383a2c 2012-06-16 kinaba: int Y = 4000; 9f60383a2c 2012-06-16 kinaba: int minT = 1; 9f60383a2c 2012-06-16 kinaba: int maxT = 20000; 9f60383a2c 2012-06-16 kinaba: int _ = -1; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(6) 9f60383a2c 2012-06-16 kinaba: int X = 3; 9f60383a2c 2012-06-16 kinaba: int Y = 3; 9f60383a2c 2012-06-16 kinaba: int minT = 1; 9f60383a2c 2012-06-16 kinaba: int maxT = 1; 9f60383a2c 2012-06-16 kinaba: int _ = 0; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: 9f60383a2c 2012-06-16 kinaba: } 9f60383a2c 2012-06-16 kinaba: // END CUT HERE