Artifact Content
Not logged in

Artifact c57ee03e6f42aff8d12b2f2222d865c7e88c793c


#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class AmebaDiv1 { public:
	int count(vector <int> X)
	{
		set<int> last(X.begin(), X.end());
		int cnt = 0;
		for(int E : last)
			if(!can_end_by(X, E))
				++cnt;
		return cnt;
	}

	bool can_end_by(const vector<int>& X, int E)
	{
		for(int B=E;;) {
			if(run(B, X) == E)
				return true;

			if(B%2==0)
				B/=2;
			else
				break;
		}
		return false;
	}

	int run(int B, const vector<int>& X)
	{
		for(int x: X)
			B = (x==B ? B*2 : B);
		return B;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::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(_, AmebaDiv1().count(X));}
int main(){

CASE(0)
	int X_[] = {3,2,1};
	  vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_)); 
	int _ = 2; 
END
CASE(1)
	int X_[] = {2,2,2,2,2,2,4,2,2,2};
	  vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_)); 
	int _ = 2; 
END
CASE(2)
	int X_[] = {1,2,4,8,16,32,64,128,256,1024,2048};
	  vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_)); 
	int _ = 11; 
END
CASE(3)
	int X_[] = {854,250,934,1000,281,250,281,467,854,562,934,1000,854,500,562};
	  vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_)); 
	int _ = 7; 
END
/*
CASE(4)
	int X_[] = ;
	  vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_)); 
	int _ = ; 
END
CASE(5)
	int X_[] = ;
	  vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_)); 
	int _ = ; 
END
*/
}
// END CUT HERE