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 EvenRoute { public: 9f60383a2c 2012-06-16 kinaba: string isItPossible(vector <int> x, vector <int> y, int wantedParity) 9f60383a2c 2012-06-16 kinaba: { 9f60383a2c 2012-06-16 kinaba: bool can = false; 9f60383a2c 2012-06-16 kinaba: for(int i=0; i<x.size(); ++i) 9f60383a2c 2012-06-16 kinaba: if( ((x[i]+y[i])&1) == wantedParity ) 9f60383a2c 2012-06-16 kinaba: can = true; 9f60383a2c 2012-06-16 kinaba: return can ? "CAN" : "CANNOT"; 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 string& Expected, const string& 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(_, EvenRoute().isItPossible(x, y, wantedParity));} 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_[] = {-1,-1,1,1}; 9f60383a2c 2012-06-16 kinaba: vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 9f60383a2c 2012-06-16 kinaba: int y_[] = {-1,1,1,-1}; 9f60383a2c 2012-06-16 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 9f60383a2c 2012-06-16 kinaba: int wantedParity = 0; 9f60383a2c 2012-06-16 kinaba: string _ = "CAN"; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(1) 9f60383a2c 2012-06-16 kinaba: int x_[] = {-5,-3,2}; 9f60383a2c 2012-06-16 kinaba: vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 9f60383a2c 2012-06-16 kinaba: int y_[] = {2,0,3}; 9f60383a2c 2012-06-16 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 9f60383a2c 2012-06-16 kinaba: int wantedParity = 1; 9f60383a2c 2012-06-16 kinaba: string _ = "CAN"; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(2) 9f60383a2c 2012-06-16 kinaba: int x_[] = {1001, -4000}; 9f60383a2c 2012-06-16 kinaba: vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 9f60383a2c 2012-06-16 kinaba: int y_[] = {0,0}; 9f60383a2c 2012-06-16 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 9f60383a2c 2012-06-16 kinaba: int wantedParity = 1; 9f60383a2c 2012-06-16 kinaba: string _ = "CAN"; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(3) 9f60383a2c 2012-06-16 kinaba: int x_[] = {11, 21, 0}; 9f60383a2c 2012-06-16 kinaba: vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 9f60383a2c 2012-06-16 kinaba: int y_[] = {-20, 42, 7}; 9f60383a2c 2012-06-16 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 9f60383a2c 2012-06-16 kinaba: int wantedParity = 0; 9f60383a2c 2012-06-16 kinaba: string _ = "CANNOT"; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(4) 9f60383a2c 2012-06-16 kinaba: int x_[] = {0, 6}; 9f60383a2c 2012-06-16 kinaba: vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 9f60383a2c 2012-06-16 kinaba: int y_[] = {10, -20}; 9f60383a2c 2012-06-16 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 9f60383a2c 2012-06-16 kinaba: int wantedParity = 1; 9f60383a2c 2012-06-16 kinaba: string _ = "CANNOT"; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(5) 9f60383a2c 2012-06-16 kinaba: int x_[] = {159833,-62665,323889,-235879,137089,-669850,137554,549764,191807,993220,-801864,-425902,326896,312318,-778686,33030,763633,-866343,36938,-627234,-19941,-909928,-920678,-763769,657773,431660,600784,54912,563394,970744,872933,-413697,319375,249696,368559,-449659,942650,997004,-420096,-473219,-757172,70934,-771310,498140,-870998,176429,985061,-674033,255167,-89503}; 9f60383a2c 2012-06-16 kinaba: vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 9f60383a2c 2012-06-16 kinaba: int y_[] = {38668,957082,-75351,-877610,-247852,458917,-417575,219160,515259,-254435,-441099,631589,-637191,-902042,-662042,-279031,-233412,-443322,207905,-566785,-248122,829715,362587,831403,-238955,792643,77852,665108,83526,-623925,-199287,492427,311357,-437880,39341,988852,-261007,-621546,-659372,-661305,196329,769159,-771255,-888939,483180,-151127,-533736,281297,411246,-339825}; 9f60383a2c 2012-06-16 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 9f60383a2c 2012-06-16 kinaba: int wantedParity = 0; 9f60383a2c 2012-06-16 kinaba: string _ = "???"; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(5) 9f60383a2c 2012-06-16 kinaba: int x_[] = {159833,-62665,323889,-235879,137089,-669850,137554,549764,191807,993220,-801864,-425902,326896,312318,-778686,33030,763633,-866343,36938,-627234,-19941,-909928,-920678,-763769,657773,431660,600784,54912,563394,970744,872933,-413697,319375,249696,368559,-449659,942650,997004,-420096,-473219,-757172,70934,-771310,498140,-870998,176429,985061,-674033,255167,-89503}; 9f60383a2c 2012-06-16 kinaba: vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 9f60383a2c 2012-06-16 kinaba: int y_[] = {38668,957082,-75351,-877610,-247852,458917,-417575,219160,515259,-254435,-441099,631589,-637191,-902042,-662042,-279031,-233412,-443322,207905,-566785,-248122,829715,362587,831403,-238955,792643,77852,665108,83526,-623925,-199287,492427,311357,-437880,39341,988852,-261007,-621546,-659372,-661305,196329,769159,-771255,-888939,483180,-151127,-533736,281297,411246,-339825}; 9f60383a2c 2012-06-16 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 9f60383a2c 2012-06-16 kinaba: int wantedParity = 1; 9f60383a2c 2012-06-16 kinaba: string _ = "???"; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(6) 9f60383a2c 2012-06-16 kinaba: int x_[] = {159833,-62665,323889,-235879,137089,-669850,137554,549764,191807,993220,-801864,-425902,326896,312318,-778686,33030,763633,-866343,36938,-627234,-19941,-909928,-920678,-763769,657773,431660,600784,54912,563394,970744,872933,-413697,319375,249696,368559,-449659,942650,997004,-420096,-473219,-757172,70934,-771310,498140,-870998,176429,985061,-674033,255167,-89503}; 9f60383a2c 2012-06-16 kinaba: vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 9f60383a2c 2012-06-16 kinaba: int y_[] = {159833,-62665,323889,-235879,137089,-669850,137554,549764,191807,993220,-801864,-425902,326896,312318,-778686,33030,763633,-866343,36938,-627234,-19941,-909928,-920678,-763769,657773,431660,600784,54912,563394,970744,872933,-413697,319375,249696,368559,-449659,942650,997004,-420096,-473219,-757172,70934,-771310,498140,-870998,176429,985061,-674033,255167,-89503}; 9f60383a2c 2012-06-16 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 9f60383a2c 2012-06-16 kinaba: int wantedParity = 0; 9f60383a2c 2012-06-16 kinaba: string _ = "???"; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: CASE(6) 9f60383a2c 2012-06-16 kinaba: int x_[] = {159833,-62665,323889,-235879,137089,-669850,137554,549764,191807,993220,-801864,-425902,326896,312318,-778686,33030,763633,-866343,36938,-627234,-19941,-909928,-920678,-763769,657773,431660,600784,54912,563394,970744,872933,-413697,319375,249696,368559,-449659,942650,997004,-420096,-473219,-757172,70934,-771310,498140,-870998,176429,985061,-674033,255167,-89503}; 9f60383a2c 2012-06-16 kinaba: vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 9f60383a2c 2012-06-16 kinaba: int y_[] = {159833,-62665,323889,-235879,137089,-669850,137554,549764,191807,993220,-801864,-425902,326896,312318,-778686,33030,763633,-866343,36938,-627234,-19941,-909928,-920678,-763769,657773,431660,600784,54912,563394,970744,872933,-413697,319375,249696,368559,-449659,942650,997004,-420096,-473219,-757172,70934,-771310,498140,-870998,176429,985061,-674033,255167,-89503}; 9f60383a2c 2012-06-16 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 9f60383a2c 2012-06-16 kinaba: int wantedParity = 1; 9f60383a2c 2012-06-16 kinaba: string _ = "???"; 9f60383a2c 2012-06-16 kinaba: END 9f60383a2c 2012-06-16 kinaba: 9f60383a2c 2012-06-16 kinaba: } 9f60383a2c 2012-06-16 kinaba: // END CUT HERE