c9001fb21d 2011-08-20 kinaba: #include <iostream> c9001fb21d 2011-08-20 kinaba: #include <sstream> c9001fb21d 2011-08-20 kinaba: #include <iomanip> c9001fb21d 2011-08-20 kinaba: #include <vector> c9001fb21d 2011-08-20 kinaba: #include <string> c9001fb21d 2011-08-20 kinaba: #include <map> c9001fb21d 2011-08-20 kinaba: #include <set> c9001fb21d 2011-08-20 kinaba: #include <algorithm> c9001fb21d 2011-08-20 kinaba: #include <numeric> c9001fb21d 2011-08-20 kinaba: #include <iterator> c9001fb21d 2011-08-20 kinaba: #include <functional> c9001fb21d 2011-08-20 kinaba: #include <complex> c9001fb21d 2011-08-20 kinaba: #include <queue> c9001fb21d 2011-08-20 kinaba: #include <stack> c9001fb21d 2011-08-20 kinaba: #include <cmath> c9001fb21d 2011-08-20 kinaba: #include <cassert> c9001fb21d 2011-08-20 kinaba: #include <cstring> c9001fb21d 2011-08-20 kinaba: using namespace std; c9001fb21d 2011-08-20 kinaba: typedef long long LL; c9001fb21d 2011-08-20 kinaba: typedef complex<double> CMP; c9001fb21d 2011-08-20 kinaba: c9001fb21d 2011-08-20 kinaba: class MagicalGirlLevelOneDivOne { public: c9001fb21d 2011-08-20 kinaba: string isReachable(vector <int> jumpTypes, int x, int y) c9001fb21d 2011-08-20 kinaba: { c9001fb21d 2011-08-20 kinaba: bool hasEven = false; c9001fb21d 2011-08-20 kinaba: for(int i=0; i<jumpTypes.size(); ++i) c9001fb21d 2011-08-20 kinaba: if( jumpTypes[i]%2 == 0 ) c9001fb21d 2011-08-20 kinaba: hasEven = true; c9001fb21d 2011-08-20 kinaba: if( hasEven ) c9001fb21d 2011-08-20 kinaba: return "YES"; c9001fb21d 2011-08-20 kinaba: else c9001fb21d 2011-08-20 kinaba: return (x+y)%2==0 ? "YES" : "NO"; c9001fb21d 2011-08-20 kinaba: } c9001fb21d 2011-08-20 kinaba: }; c9001fb21d 2011-08-20 kinaba: c9001fb21d 2011-08-20 kinaba: // BEGIN CUT HERE c9001fb21d 2011-08-20 kinaba: #include <ctime> c9001fb21d 2011-08-20 kinaba: double start_time; string timer() c9001fb21d 2011-08-20 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } c9001fb21d 2011-08-20 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) c9001fb21d 2011-08-20 kinaba: { os << "{ "; c9001fb21d 2011-08-20 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) c9001fb21d 2011-08-20 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } c9001fb21d 2011-08-20 kinaba: void verify_case(const string& Expected, const string& Received) { c9001fb21d 2011-08-20 kinaba: bool ok = (Expected == Received); c9001fb21d 2011-08-20 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; c9001fb21d 2011-08-20 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } c9001fb21d 2011-08-20 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); c9001fb21d 2011-08-20 kinaba: #define END verify_case(_, MagicalGirlLevelOneDivOne().isReachable(jumpTypes, x, y));} c9001fb21d 2011-08-20 kinaba: int main(){ c9001fb21d 2011-08-20 kinaba: c9001fb21d 2011-08-20 kinaba: CASE(0) c9001fb21d 2011-08-20 kinaba: int jumpTypes_[] = {2}; c9001fb21d 2011-08-20 kinaba: vector <int> jumpTypes(jumpTypes_, jumpTypes_+sizeof(jumpTypes_)/sizeof(*jumpTypes_)); c9001fb21d 2011-08-20 kinaba: int x = 5; c9001fb21d 2011-08-20 kinaba: int y = 4; c9001fb21d 2011-08-20 kinaba: string _ = "YES"; c9001fb21d 2011-08-20 kinaba: END c9001fb21d 2011-08-20 kinaba: CASE(1) c9001fb21d 2011-08-20 kinaba: int jumpTypes_[] = {3}; c9001fb21d 2011-08-20 kinaba: vector <int> jumpTypes(jumpTypes_, jumpTypes_+sizeof(jumpTypes_)/sizeof(*jumpTypes_)); c9001fb21d 2011-08-20 kinaba: int x = 5; c9001fb21d 2011-08-20 kinaba: int y = 4; c9001fb21d 2011-08-20 kinaba: string _ = "NO"; c9001fb21d 2011-08-20 kinaba: END c9001fb21d 2011-08-20 kinaba: CASE(2) c9001fb21d 2011-08-20 kinaba: int jumpTypes_[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; c9001fb21d 2011-08-20 kinaba: vector <int> jumpTypes(jumpTypes_, jumpTypes_+sizeof(jumpTypes_)/sizeof(*jumpTypes_)); c9001fb21d 2011-08-20 kinaba: int x = 1000000000; c9001fb21d 2011-08-20 kinaba: int y = -999999999; c9001fb21d 2011-08-20 kinaba: string _ = "YES"; c9001fb21d 2011-08-20 kinaba: END c9001fb21d 2011-08-20 kinaba: CASE(3) c9001fb21d 2011-08-20 kinaba: int jumpTypes_[] = {999999999}; c9001fb21d 2011-08-20 kinaba: vector <int> jumpTypes(jumpTypes_, jumpTypes_+sizeof(jumpTypes_)/sizeof(*jumpTypes_)); c9001fb21d 2011-08-20 kinaba: int x = 999999999; c9001fb21d 2011-08-20 kinaba: int y = 0; c9001fb21d 2011-08-20 kinaba: string _ = "NO"; c9001fb21d 2011-08-20 kinaba: END c9001fb21d 2011-08-20 kinaba: /* c9001fb21d 2011-08-20 kinaba: CASE(4) c9001fb21d 2011-08-20 kinaba: int jumpTypes_[] = ; c9001fb21d 2011-08-20 kinaba: vector <int> jumpTypes(jumpTypes_, jumpTypes_+sizeof(jumpTypes_)/sizeof(*jumpTypes_)); c9001fb21d 2011-08-20 kinaba: int x = ; c9001fb21d 2011-08-20 kinaba: int y = ; c9001fb21d 2011-08-20 kinaba: string _ = ; c9001fb21d 2011-08-20 kinaba: END c9001fb21d 2011-08-20 kinaba: CASE(5) c9001fb21d 2011-08-20 kinaba: int jumpTypes_[] = ; c9001fb21d 2011-08-20 kinaba: vector <int> jumpTypes(jumpTypes_, jumpTypes_+sizeof(jumpTypes_)/sizeof(*jumpTypes_)); c9001fb21d 2011-08-20 kinaba: int x = ; c9001fb21d 2011-08-20 kinaba: int y = ; c9001fb21d 2011-08-20 kinaba: string _ = ; c9001fb21d 2011-08-20 kinaba: END c9001fb21d 2011-08-20 kinaba: */ c9001fb21d 2011-08-20 kinaba: } c9001fb21d 2011-08-20 kinaba: // END CUT HERE