ADDED SRM/625-U/1A.cpp Index: SRM/625-U/1A.cpp ================================================================== --- SRM/625-U/1A.cpp +++ SRM/625-U/1A.cpp @@ -0,0 +1,100 @@ +#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 BuildingHeights { public: + int minimum(vector heights) + { + const int N = heights.size(); + sort(heights.begin(), heights.end()); + vector sum(N+1); + partial_sum(heights.begin(), heights.end(), sum.begin()+1); + + vector A(N, 0x7fffffff); + for(int s=0; s +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(_, BuildingHeights().minimum(heights));} +int main(){ + +CASE(0) + int heights_[] = {1, 5, 4, 3, 8}; + vector heights(heights_, heights_+sizeof(heights_)/sizeof(*heights_)); + int _ = 22; +END +CASE(1) + int heights_[] = {1, 2, 3}; + vector heights(heights_, heights_+sizeof(heights_)/sizeof(*heights_)); + int _ = 2; +END +CASE(2) + int heights_[] = {3, 4, 1, 6, 8, 1}; + vector heights(heights_, heights_+sizeof(heights_)/sizeof(*heights_)); + int _ = 21; +END +CASE(3) + int heights_[] = {990, 20, 2359, 1667, 51, 2455, 1659, 1093, 2015, 205, 656, 752, 1760, 1594, 857, + 2033, 1868, 1932, 2408, 1518, 91, 2220, 1696, 1552, 933, 143, 1888, 1261, 2298, 1975, + 929, 2139, 1994, 2139, 158, 896, 2093, 1816, 841, 459, 2020, 1496, 63, 131, 589, 919, + 1015, 1308, 350, 922, 326, 1792, 641, 2021, 843, 425, 1015, 231, 1685, 2165, 1057, + 1465, 655, 550, 1103, 812, 297, 2048, 1479, 1137, 6, 2350, 1484, 1420, 1332, 925, 2338, + 1198, 2232, 1539, 2119, 57, 830, 1611, 929, 525, 888}; + vector heights(heights_, heights_+sizeof(heights_)/sizeof(*heights_)); + int _ = 56068; +END +/* +CASE(4) + int heights_[] = ; + vector heights(heights_, heights_+sizeof(heights_)/sizeof(*heights_)); + int _ = ; +END +CASE(5) + int heights_[] = ; + vector heights(heights_, heights_+sizeof(heights_)/sizeof(*heights_)); + int _ = ; +END +*/ +} +// END CUT HERE ADDED SRM/625-U/1B.cpp Index: SRM/625-U/1B.cpp ================================================================== --- SRM/625-U/1B.cpp +++ SRM/625-U/1B.cpp cannot compute difference between binary files ADDED SRM/625-U/1C-U.cpp Index: SRM/625-U/1C-U.cpp ================================================================== --- SRM/625-U/1C-U.cpp +++ SRM/625-U/1C-U.cpp @@ -0,0 +1,148 @@ +#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 TreeColoring { public: + long long color(int N, int Q, int startSeed, int threshold, int maxDist) + { + vector parent(N-1), distance(N-1), queryType(Q), queryNode(Q); + { + int curValue = startSeed; + function genNextRandom = [&]() { + curValue = (curValue * 1999 + 17) % 1000003; + return curValue; + }; + for(int i=0; i> p(N, vector(17, INVALID)); + vector d(N); + for(int v=1; v +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(_, TreeColoring().color(N, Q, startSeed, threshold, maxDist));} +int main(){ + +CASE(0) + int N = 4; + int Q = 6; + int startSeed = 15; + int threshold = 2; + int maxDist = 5; + long long _ = 7LL; +END +CASE(1) + int N = 4; + int Q = 5; + int startSeed = 2; + int threshold = 9; + int maxDist = 10; + long long _ = 30LL; +END +CASE(2) + int N = 8; + int Q = 8; + int startSeed = 3; + int threshold = 5; + int maxDist = 7; + long long _ = 6LL; +END +CASE(3) + int N = 14750; + int Q = 50; + int startSeed = 29750; + int threshold = 1157; + int maxDist = 21610; + long long _ = 2537640LL; +END +CASE(4) + int N = 100000; + int Q = 100000; + int startSeed = 123456; + int threshold = 500000; + int maxDist = 474747; + long long _ = 726915029831LL; +END +CASE(5) + int N = 100000; + int Q = 100000; + int startSeed = 654321; + int threshold = 1000003; + int maxDist = 1000003; + long long _ = 562600687570528LL; +END +/* +CASE(6) + int N = ; + int Q = ; + int startSeed = ; + int threshold = ; + int maxDist = ; + long long _ = LL; +END +CASE(7) + int N = ; + int Q = ; + int startSeed = ; + int threshold = ; + int maxDist = ; + long long _ = LL; +END +*/ +} +// END CUT HERE