ADDED SRM/694-U/1A.cpp Index: SRM/694-U/1A.cpp ================================================================== --- SRM/694-U/1A.cpp +++ SRM/694-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 TrySail { public: + int get(vector strength) + { + vector possible(65536, false); + possible[0] = true; + for(int s: strength) { + vector p2 = possible; + for(int a=0; a<256; ++a) + for(int b=0; b<256; ++b) if(possible[a*256+b]) + p2[(a^s)*256+b] = p2[a*256+(b^s)] = true; + possible.swap(p2); + } + + int all = 0; + for(int s: strength) all ^= s; + + int best = 0; + for(int a=0; a<256; ++a) + for(int b=0; b<256; ++b) if(possible[a*256+b]) + best = max(best, a+b+(all^a^b)); + return best; + } +}; + +// 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(_, TrySail().get(strength));} +int main(){ + +CASE(0) + int strength_[] = {2,3,3}; + vector strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); + int _ = 8; +END +CASE(1) + int strength_[] = {7,3,5,2}; + vector strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); + int _ = 17; +END +CASE(2) + int strength_[] = {13,13,13,13,13,13,13,13}; + vector strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); + int _ = 26; +END +CASE(3) + int strength_[] = {114,51,4,191,9,81,0,89,3}; + vector strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); + int _ = 470; +END +CASE(4) + int strength_[] = {108,66,45,82,163,30,83,244,200,216,241,249,89,128,36,28,250,190,70,95,117,196,19,160,255,129,10,109,189,24,22,25,134,144,110,15,235,205,186,103,116,191,119,183,45,217,156,44,97,197}; + vector strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); + int _ = 567; +END +/* +CASE(5) + int strength_[] = ; + vector strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); + int _ = ; +END +CASE(6) + int strength_[] = ; + vector strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); + int _ = ; +END +*/ +} +// END CUT HERE ADDED SRM/694-U/1B.cpp Index: SRM/694-U/1B.cpp ================================================================== --- SRM/694-U/1B.cpp +++ SRM/694-U/1B.cpp cannot compute difference between binary files