Index: CheckList.pptx ================================================================== --- CheckList.pptx +++ CheckList.pptx cannot compute difference between binary files ADDED SRM/557-U/1A.cpp Index: SRM/557-U/1A.cpp ================================================================== --- SRM/557-U/1A.cpp +++ SRM/557-U/1A.cpp @@ -0,0 +1,141 @@ +#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 FoxAndMountainEasy { public: + string possible(int n, int h0, int hn, string history) + { + int z = 0; + int min_z = 0; + for(int i=0; i +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 string& Expected, const string& 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(_, FoxAndMountainEasy().possible(n, h0, hn, history));} +int main(){ + +CASE(0) + int n = 4; + int h0 = 0; + int hn = 4; + string history = "UU"; + string _ = "YES"; +END +CASE(1) + int n = 4; + int h0 = 0; + int hn = 4; + string history = "D"; + string _ = "NO"; +END +CASE(2) + int n = 4; + int h0 = 100000; + int hn = 100000; + string history = "DDU"; + string _ = "YES"; +END +CASE(3) + int n = 4; + int h0 = 0; + int hn = 0; + string history = "DDU"; + string _ = "NO"; +END +CASE(4) + int n = 20; + int h0 = 20; + int hn = 20; + string history = "UDUDUDUDUD"; + string _ = "YES"; +END +CASE(5) + int n = 20; + int h0 = 0; + int hn = 0; + string history = "UUUUUUUUUU"; + string _ = "YES"; +END +CASE(6) + int n = 20; + int h0 = 0; + int hn = 0; + string history = "UUUUUUUUUUU"; + string _ = "NO"; +END +CASE(7) + int n = 4; + int h0 = 3; + int hn = 1; + string history = "U"; + string _ = "YES"; +END +CASE(8) + int n = 1; + int h0 = 0; + int hn = 1; + string history = "U"; + string _ = "YES"; +END +CASE(8) + int n = 2; + int h0 = 0; + int hn = 0; + string history = "DU"; + string _ = "NO"; +END +} +// END CUT HERE ADDED SRM/557-U/1B.cpp Index: SRM/557-U/1B.cpp ================================================================== --- SRM/557-U/1B.cpp +++ SRM/557-U/1B.cpp @@ -0,0 +1,145 @@ +#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; + +typedef int vert; +typedef vert edge; +typedef vector edges; +typedef vector graph; + +bool augment( graph& G, int v, vector& matchTo, bool visited[] ) +{ + for(int i=0; i +int biMatch( graph& G, int L ) // [0,L):left, [L,?):right + // only left->right edges are used during computation +{ + vector matchTo(G.size(), -1); + int ans = 0; + for(vert v=0; v love) + { + const int N = love.size(); + vector< vector > protects(N, vector(N, false)); + for(int i=0; i(G, N); + } +}; + +// 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 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(_, Incubator().maxMagicalGirls(love));} +int main(){ + +CASE(0) + string love_[] = {"NY","NN"}; + vector love(love_, love_+sizeof(love_)/sizeof(*love_)); + int _ = 1; +END +CASE(1) + string love_[] = {"NYN", "NNY", "NNN"}; + vector love(love_, love_+sizeof(love_)/sizeof(*love_)); + int _ = 1; +END +CASE(2) + string love_[] = {"NNYNN","NNYNN","NNNYY","NNNNN","NNNNN"}; + vector love(love_, love_+sizeof(love_)/sizeof(*love_)); + int _ = 2; +END +CASE(3) + string love_[] = {"NNNNN","NYNNN","NYNYN","YNYNN","NNNNN"}; + vector love(love_, love_+sizeof(love_)/sizeof(*love_)); + int _ = 2; +END +CASE(4) + string love_[] = {"NNNNN","NNNNN","NNNNN","NNNNN","NNNNN"}; + vector love(love_, love_+sizeof(love_)/sizeof(*love_)); + int _ = 5; +END +CASE(5) + string love_[] = {"NNYNNNNN","NNNYNNNN","NNNNYNNN","NNYNNNNN","NNNNNYYN","NNNYNNNY","NNNNNNNN","NNNNNNNN"}; + vector love(love_, love_+sizeof(love_)/sizeof(*love_)); + int _ = 2; +END +CASE(6) + string love_[] = {"Y"}; + vector love(love_, love_+sizeof(love_)/sizeof(*love_)); + int _ = 0; +END +CASE(7) + string love_[] = {"NYNNN", "NNYNN", "NNYYY", "NNYYY", "NNYYY"}; + vector love(love_, love_+sizeof(love_)/sizeof(*love_)); + int _ = 1; +END +CASE(8) +string love_[] = {"NNYYYYY", "NNYYYYY", "NNNNNNN", "NNNYYYY", "NNNYYYY", "NNNYYYY", "NNNYYYY"}; + vector love(love_, love_+sizeof(love_)/sizeof(*love_)); + int _ = 2; +END +} +// END CUT HERE