Artifact Content
Not logged in

Artifact e66651725115e70a54b69f2083190225e3fb35f6


#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>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef complex<LD> CMP;

static const unsigned MODVAL = 1000000007;
struct mint
{
	unsigned val;
	mint():val(0){}
	mint(int      x):val(x%MODVAL) {}
	mint(unsigned x):val(x%MODVAL) {}
	mint(LL       x):val(x%MODVAL) {}
};
mint& operator+=(mint& x, mint y) { return x = x.val+y.val; }
mint& operator-=(mint& x, mint y) { return x = x.val-y.val+MODVAL; }
mint& operator*=(mint& x, mint y) { return x = LL(x.val)*y.val; }
mint operator+(mint x, mint y) { return x+=y; }
mint operator-(mint x, mint y) { return x-=y; }
mint operator*(mint x, mint y) { return x*=y; }

mint POW(mint x, LL e) { mint v=1; for(;e;x*=x,e>>=1) if(e&1) v*=x; return v; }
mint& operator/=(mint& x, mint y) { return x *= POW(y, MODVAL-2); }
mint operator/(mint x, mint y) { return x/=y; }

class DefectiveAddition { public:
	int count(vector <int> cards, int n)
	{
		int n_msb = 0;
		while( (1<<n_msb+1) <= n ) {}

		vector<int> cc(30);
		vector<int> more;
		for(int i=0; i<cards.size(); ++i) {
			for(int k=0; k<=29; ++k)
			{
				if((1<<k)<=cards[i] && cards[i]<(1<<k+1))
					cc[k].push_back(cards[i]);
			}
		}

		mint p = 0;
		for(int k=29; k>=0; --k)
		{
			int BIT = (n>>k)&1;

			int up = 0;

			vector<int> rel;
			for(int i=0; i<cards.size(); ++i)
				if( (1<<k) <= cards[i] ) {
					if( (1<<k+1) <= cards[i] )
						up ^= cards[i];
					if( (1<<k) & cards[i] )
						rel.push_back(i);
				}

			// all take above
			if( (up>>k+1) == (n>>k+1) )
			{
				for(int ri=0; ri<rel.size(); ++ri)
				{
					int i = rel[ri];
				}
			}
		}
		return p.val;
	}
};

// 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(_, DefectiveAddition().count(cards, n));}
int main(){

CASE(0)
	int cards_[] = {2,3};
	  vector <int> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
	int n = 2; 
	int _ = 3; 
END
CASE(1)
	int cards_[] = {1,2,3};
	  vector <int> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
	int n = 1; 
	int _ = 6; 
END
CASE(2)
	int cards_[] = {4, 5, 7, 11};
	  vector <int> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
	int n = 6; 
	int _ = 240; 
END
CASE(3)
	int cards_[] = {1,2,3,4,5,6,7,8,9,10};
	  vector <int> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
	int n = 15; 
	int _ = 1965600; 
END
CASE(4)
	int cards_[] = {1,2,3,4,5,6,7,8,9,10};
	  vector <int> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
	int n = 16; 
	int _ = 0; 
END
CASE(5)
	int cards_[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
	  vector <int> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
	int n = 1; 
	int _ = 949480669; 
END
/*
CASE(6)
	int cards_[] = ;
	  vector <int> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
	int n = ; 
	int _ = ; 
END
CASE(7)
	int cards_[] = ;
	  vector <int> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
	int n = ; 
	int _ = ; 
END
*/
}
// END CUT HERE