Index: CheckList.pptx ================================================================== --- CheckList.pptx +++ CheckList.pptx cannot compute difference between binary files ADDED SRM/570-U/1A.cpp Index: SRM/570-U/1A.cpp ================================================================== --- SRM/570-U/1A.cpp +++ SRM/570-U/1A.cpp @@ -0,0 +1,107 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +typedef long long LL; +typedef long double LD; +typedef complex CMP; + +class RobotHerb { public: + long long getdist(int T, vector a) + { + static const LL dx[] = {+1,0,-1,0}; + static const LL dy[] = {0,+1,0,-1}; + + LL x=0, y=0, d=0, xs[5]={}, ys[5]={}; + for(int i=0; i<4; ++i) + { + for(int k=0; k +double start_time; string timer() + { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } +template ostream& operator<<(ostream& os, const vector& v) + { os << "{ "; + for(typename vector::const_iterator it=v.begin(); it!=v.end(); ++it) + os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } +void verify_case(const long long& Expected, const long long& 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(_, RobotHerb().getdist(T, a));} +int main(){ + +CASE(0) + int T = 1; + int a_[] = {1,2,3}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + long long _ = 2LL; +END +CASE(1) + int T = 100; + int a_[] = {1}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + long long _ = 0LL; +END +CASE(2) + int T = 5; + int a_[] = {1,1,2}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + long long _ = 10LL; +END +CASE(3) + int T = 1000000000; + int a_[] = {100}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + long long _ = 100000000000LL; +END +CASE(4) + int T = 570; + int a_[] = {2013,2,13,314,271,1414,1732}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + long long _ = 4112LL; +END +/* +CASE(5) + int T = ; + int a_[] = ; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + long long _ = LL; +END +CASE(6) + int T = ; + int a_[] = ; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + long long _ = LL; +END +*/ +} +// END CUT HERE ADDED SRM/570-U/1B.cpp Index: SRM/570-U/1B.cpp ================================================================== --- SRM/570-U/1B.cpp +++ SRM/570-U/1B.cpp @@ -0,0 +1,169 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +typedef long long LL; +typedef long double LD; +typedef complex CMP; + +class CentaurCompany { public: + struct State { + int nNode; + vector< vector< vector > > th; // nHumanNodes -> nEq -> nEq -> prob + vector< vector< vector > > tk; // nHumanNodes -> nEq -> nEq -> prob + }; + + double getvalue(vector a, vector b) + { + int N = a.size() + 1; + vector< vector > G(N); + for(int i=0; i >& G) + { + State s = {1, + vector< vector< vector > >(2, vector< vector >(2, vector(2))), + vector< vector< vector > >(2, vector< vector >(2, vector(2))) + }; + s.th[1][1][0] = 0.5; + s.tk[0][0][1] = 0.5; + for(int i=0; i > >(N+1, vector< vector >(N+1, vector(N+1))), + vector< vector< vector > >(N+1, vector< vector >(N+1, vector(N+1))) + }; + for(int ah=0; ah<=a.nNode; ++ah) + for(int ahe=0; ahe<=ah; ++ahe) + for(int ake=0; ake<=(a.nNode-ah); ++ake) + for(int bh=0; bh<=b.nNode; ++bh) + for(int bhe=0; bhe<=bh; ++bhe) + for(int bke=0; bke<=(b.nNode-bh); ++bke) { + if(ahe+bhe!=0) + s.th[ah+bh][ahe+bhe-1][ake+bke] += a.th[ah][ahe][ake]*b.th[bh][bhe][bke]; + s.th[ah+bh][ahe+bhe][ake+bke] += a.th[ah][ahe][ake]*b.tk[bh][bhe][bke]; + s.tk[ah+bh][ahe+bhe][ake+bke] += a.tk[ah][ahe][ake]*b.th[bh][bhe][bke]; + if(ake+bke!=0) + s.tk[ah+bh][ahe+bhe][ake+bke-1] += a.tk[ah][ahe][ake]*b.tk[bh][bhe][bke]; + } + return s; + } +}; + +// BEGIN CUT HERE +#include +double start_time; string timer() + { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } +template ostream& operator<<(ostream& os, const vector& v) + { os << "{ "; + for(typename vector::const_iterator it=v.begin(); it!=v.end(); ++it) + os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } +void verify_case(const double& Expected, const double& Received) { + bool ok = (abs(Expected - Received) < 1e-9); + 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(_, CentaurCompany().getvalue(a, b));} +int main(){ + +CASE(0) + int a_[] = {1}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + int b_[] = {2}; + vector b(b_, b_+sizeof(b_)/sizeof(*b_)); + double _ = 0.0; +END +CASE(1) + int a_[] = {1,1,1}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + int b_[] = {2,3,4}; + vector b(b_, b_+sizeof(b_)/sizeof(*b_)); + double _ = 0.125; +END +CASE(2) + int a_[] = {1,2,3,2,2}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + int b_[] = {2,3,4,5,6}; + vector b(b_, b_+sizeof(b_)/sizeof(*b_)); + double _ = 0.375; +END +CASE(3) + int a_[] = {1,2,3,4,5,6,7,8,9}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + int b_[] = {2,3,4,5,6,7,8,9,10}; + vector b(b_, b_+sizeof(b_)/sizeof(*b_)); + double _ = 0.41796875; +END +CASE(4) + int a_[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + int b_[] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36}; + vector b(b_, b_+sizeof(b_)/sizeof(*b_)); + double _ = 15.500000001076842; +END +CASE(5) + int a_[] = {10, 7, 2, 5, 6, 2, 4, 9, 7}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + int b_[] = {8, 10, 10, 4, 1, 6, 2, 2, 3}; + vector b(b_, b_+sizeof(b_)/sizeof(*b_)); + double _ = 0.646484375; +END +CASE(6) + int a_[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35}; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + int b_[] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36}; + vector b(b_, b_+sizeof(b_)/sizeof(*b_)); + double _ = -1; +END +/* +CASE(7) + int a_[] = ; + vector a(a_, a_+sizeof(a_)/sizeof(*a_)); + int b_[] = ; + vector b(b_, b_+sizeof(b_)/sizeof(*b_)); + double _ = ; +END +*/ +} +// END CUT HERE