ADDED SRM/636-U/1A.cpp Index: SRM/636-U/1A.cpp ================================================================== --- SRM/636-U/1A.cpp +++ SRM/636-U/1A.cpp @@ -0,0 +1,112 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +typedef long long LL; +typedef complex CMP; + +class ChocolateDividingEasy { public: + int findBest(vector chocolate) + { + const int H = chocolate.size(); + const int W = chocolate[0].size(); + vector> sum(H+1, vector(W+1)); + for(int y=H-1; y>=0; --y) + for(int x=W-1; x>=0; --x) + sum[y][x] = (chocolate[y][x]-'0')+sum[y+1][x]+sum[y][x+1]-sum[y+1][x+1]; + + int best = 0; + for(int y1=1; y1 +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 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(_, ChocolateDividingEasy().findBest(chocolate));} +int main(){ + +CASE(0) + string chocolate_[] = { +"9768", +"6767", +"5313" +}; + vector chocolate(chocolate_, chocolate_+sizeof(chocolate_)/sizeof(*chocolate_)); + int _ = 3; +END +CASE(1) + string chocolate_[] = { +"36753562", +"91270936", +"06261879", +"20237592", +"28973612", +"93194784" +}; + vector chocolate(chocolate_, chocolate_+sizeof(chocolate_)/sizeof(*chocolate_)); + int _ = 15; +END +CASE(2) + string chocolate_[] = { +"012", +"345", +"678" +}; + vector chocolate(chocolate_, chocolate_+sizeof(chocolate_)/sizeof(*chocolate_)); + int _ = 0; +END +/* +CASE(3) + string chocolate_[] = ; + vector chocolate(chocolate_, chocolate_+sizeof(chocolate_)/sizeof(*chocolate_)); + int _ = ; +END +CASE(4) + string chocolate_[] = ; + vector chocolate(chocolate_, chocolate_+sizeof(chocolate_)/sizeof(*chocolate_)); + int _ = ; +END +*/ +} +// END CUT HERE ADDED SRM/636-U/1C.cpp Index: SRM/636-U/1C.cpp ================================================================== --- SRM/636-U/1C.cpp +++ SRM/636-U/1C.cpp cannot compute difference between binary files