Check-in [e474130ec2]
Not logged in
Overview
SHA1 Hash:e474130ec2448da235868567499de576c5c6683f
Date: 2016-08-18 10:45:59
User: kinaba
Comment:694
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Added SRM/694-U/1A.cpp version [e7f35b629801f13b]

1 +#include <iostream> 2 +#include <sstream> 3 +#include <iomanip> 4 +#include <vector> 5 +#include <string> 6 +#include <map> 7 +#include <set> 8 +#include <algorithm> 9 +#include <numeric> 10 +#include <iterator> 11 +#include <functional> 12 +#include <complex> 13 +#include <queue> 14 +#include <stack> 15 +#include <cmath> 16 +#include <cassert> 17 +#include <tuple> 18 +using namespace std; 19 +typedef long long LL; 20 +typedef complex<double> CMP; 21 + 22 +class TrySail { public: 23 + int get(vector <int> strength) 24 + { 25 + vector<bool> possible(65536, false); 26 + possible[0] = true; 27 + for(int s: strength) { 28 + vector<bool> p2 = possible; 29 + for(int a=0; a<256; ++a) 30 + for(int b=0; b<256; ++b) if(possible[a*256+b]) 31 + p2[(a^s)*256+b] = p2[a*256+(b^s)] = true; 32 + possible.swap(p2); 33 + } 34 + 35 + int all = 0; 36 + for(int s: strength) all ^= s; 37 + 38 + int best = 0; 39 + for(int a=0; a<256; ++a) 40 + for(int b=0; b<256; ++b) if(possible[a*256+b]) 41 + best = max(best, a+b+(all^a^b)); 42 + return best; 43 + } 44 +}; 45 + 46 +// BEGIN CUT HERE 47 +#include <ctime> 48 +double start_time; string timer() 49 + { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } 50 +template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) 51 + { os << "{ "; 52 + for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) 53 + os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } 54 +void verify_case(const int& Expected, const int& Received) { 55 + bool ok = (Expected == Received); 56 + if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; 57 + cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } 58 +#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); 59 +#define END verify_case(_, TrySail().get(strength));} 60 +int main(){ 61 + 62 +CASE(0) 63 + int strength_[] = {2,3,3}; 64 + vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); 65 + int _ = 8; 66 +END 67 +CASE(1) 68 + int strength_[] = {7,3,5,2}; 69 + vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); 70 + int _ = 17; 71 +END 72 +CASE(2) 73 + int strength_[] = {13,13,13,13,13,13,13,13}; 74 + vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); 75 + int _ = 26; 76 +END 77 +CASE(3) 78 + int strength_[] = {114,51,4,191,9,81,0,89,3}; 79 + vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); 80 + int _ = 470; 81 +END 82 +CASE(4) 83 + 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}; 84 + vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); 85 + int _ = 567; 86 +END 87 +/* 88 +CASE(5) 89 + int strength_[] = ; 90 + vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); 91 + int _ = ; 92 +END 93 +CASE(6) 94 + int strength_[] = ; 95 + vector <int> strength(strength_, strength_+sizeof(strength_)/sizeof(*strength_)); 96 + int _ = ; 97 +END 98 +*/ 99 +} 100 +// END CUT HERE

Added SRM/694-U/1B.cpp version [5c87b9f201ff46b9]

cannot compute difference between binary files