結果

問題 No.462 6日知らずのコンピュータ
ユーザー shimomireshimomire
提出日時 2016-12-13 02:41:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 7,922 bytes
コンパイル時間 1,357 ms
コンパイル使用メモリ 134,432 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-07 09:05:27
合計ジャッジ時間 3,077 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 AC 1 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 2 ms
5,376 KB
testcase_58 AC 2 ms
5,376 KB
testcase_59 AC 2 ms
5,376 KB
testcase_60 AC 1 ms
5,376 KB
testcase_61 AC 1 ms
5,376 KB
testcase_62 AC 2 ms
5,376 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 1 ms
5,376 KB
testcase_65 AC 2 ms
5,376 KB
testcase_66 AC 1 ms
5,376 KB
testcase_67 AC 2 ms
5,376 KB
testcase_68 AC 1 ms
5,376 KB
testcase_69 AC 2 ms
5,376 KB
testcase_70 AC 2 ms
5,376 KB
testcase_71 AC 1 ms
5,376 KB
testcase_72 AC 2 ms
5,376 KB
testcase_73 AC 1 ms
5,376 KB
testcase_74 AC 2 ms
5,376 KB
testcase_75 AC 2 ms
5,376 KB
testcase_76 AC 2 ms
5,376 KB
testcase_77 AC 1 ms
5,376 KB
testcase_78 AC 1 ms
5,376 KB
testcase_79 AC 1 ms
5,376 KB
testcase_80 AC 2 ms
5,376 KB
testcase_81 AC 1 ms
5,376 KB
testcase_82 AC 2 ms
5,376 KB
testcase_83 AC 2 ms
5,376 KB
testcase_84 WA -
testcase_85 AC 2 ms
5,376 KB
testcase_86 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>// c
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>
using namespace std;

typedef long long ll;typedef unsigned long long ull;typedef long double ld;

#define ALL(c) c.begin(),c.end()
#define IN(l,v,r) (l<=v && v < r)
template<class T> void UNIQUE(T& v){v.erase(unique(ALL(v)),v.end());}
//debug
#define DUMP(x) cerr << #x <<" = " << (x)
#define LINE() cerr<< " (L" << __LINE__ << ")"

struct range{
	struct Iter{
		int v,step;
		Iter& operator++(){v+=step;return *this;}
		bool operator!=(Iter& itr){return v<itr.v;}
		int& operator*(){return v;}
	};
	Iter i, n;
	range(int i, int n,int step):i({i,step}), n({n,step}){}
	range(int i, int n):range(i,n,1){}
	range(int n):range(0,n){}
	Iter& begin(){return i;}
	Iter& end(){return n;}
};
struct rrange{
	struct Iter{
		int v,step;
		Iter& operator++(){v-=step;return *this;}
		bool operator!=(Iter& itr){return v>itr.v;}
		int& operator*(){return v;}
	};
	Iter i, n;
	rrange(int i, int n,int step):i({i-1,step}), n({n-1,step}){}
	rrange(int i, int n):rrange(i,n,1){}
	rrange(int n) :rrange(0,n){}
	Iter& begin(){return n;}
	Iter& end(){return i;}
};

//input
template<typename T1,typename T2> istream& operator >> (istream& is,pair<T1,T2>& p){return is>>p.first>>p.second;}
template<typename T1> istream& operator >> (istream& is,tuple<T1>& t){return is >> get<0>(t);}
template<typename T1,typename T2> istream& operator >> (istream& is,tuple<T1,T2>& t){return is >> get<0>(t) >> get<1>(t);}
template<typename T1,typename T2,typename T3> istream& operator >> (istream& is,tuple<T1,T2,T3>& t){return is >>get<0>(t)>>get<1>(t)>>get<2>(t);}
template<typename T1,typename T2,typename T3,typename T4> istream& operator >> (istream& is,tuple<T1,T2,T3,T4>& t){return is >> get<0>(t)>>get<1>(t)>>get<2>(t)>>get<3>(t);}
template<typename T> istream& operator >> (istream& is,vector<T>& as){for(int i:range(as.size()))is >>as[i];return is;}
//output
template<typename T> ostream& operator << (ostream& os, const set<T>& ss){for(auto a:ss){if(a!=ss.begin())os<<" "; os<<a;}return os;}
template<typename T1,typename T2> ostream& operator << (ostream& os, const pair<T1,T2>& p){return os<<p.first<<" "<<p.second;}
template<typename K,typename V> ostream& operator << (ostream& os, const map<K,V>& m){bool isF=true;for(auto& p:m){if(!isF)os<<endl;os<<p;isF=false;}return os;}
template<typename T1> ostream& operator << (ostream& os, const tuple<T1>& t){return os << get<0>(t);}
template<typename T1,typename T2> ostream& operator << (ostream& os, const tuple<T1,T2>& t){return os << get<0>(t)<<" "<<get<1>(t);}
template<typename T1,typename T2,typename T3> ostream& operator << (ostream& os, const tuple<T1,T2,T3>& t){return os << get<0>(t)<<" "<<get<1>(t)<<" "<<get<2>(t);}
template<typename T1,typename T2,typename T3,typename T4> ostream& operator << (ostream& os, const tuple<T1,T2,T3,T4>& t){return os << get<0>(t)<<" "<<get<1>(t)<<" "<<get<2>(t)<<" "<<get<3>(t);}
template<typename T> ostream& operator << (ostream& os, const vector<T>& as){for(int i:range(as.size())){if(i!=0)os<<" "; os<<as[i];}return os;}
template<typename T> ostream& operator << (ostream& os, const vector<vector<T>>& as){for(int i:range(as.size())){if(i!=0)os<<endl; os<<as[i];}return os;}

// values
template<typename T> inline T INF(){assert(false);};
template<> inline int INF<int>(){return 1<<28;};
template<> inline ll INF<ll>(){return 1LL<<60;};
template<> inline double INF<double>(){return 1e16;};
template<> inline long double INF<long double>(){return 1e16;};

template<class T> inline T EPS(){assert(false);};
template<> inline int EPS<int>(){return 1;};
template<> inline ll EPS<ll>(){return 1LL;};
template<> inline double EPS<double>(){return 1e-8;};
template<> inline long double EPS<long double>(){return 1e-8;};

// min{2^r | n < 2^r}
template<typename T> inline T upper_pow2(T n){ T res=1;while(res<n)res<<=1;return res;}
// max{d | 2^d  <= n}
template<typename T> inline T msb(T n){ int d=62;while((1LL<<d)>n)d--;return d;}

template<typename T,typename U> T pmod(T v,U M){return (v%M+M)%M;}


ll mod = 1e9+7;
struct mint{
    ll x;
    mint(ll x):x((x%mod+mod)%mod){}
    mint():mint(0){}
    mint operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
    mint operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
    mint operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
    mint operator+(const mint& a)const{ return mint(*this) += a;}
    mint operator-(const mint& a)const{ return mint(*this) -= a;}
    mint operator*(const mint& a)const{ return mint(*this) *= a;}
    bool operator==(const mint& a)const{ return x == a.x;}

    // O(logN)
    mint pow(ll N){
        mint r(1),x = *this;
        while(N){
            if(N&1) r *= x;
            N /= 2;
            x *= x;
        }
        return r;
    }
    mint minv(){return pow(mod-2);}
};
istream& operator >> (istream& is,mint& p){return is>>p.x;}
ostream& operator << (ostream& os,mint m){os << m.x;return os;}

struct mutil{
    //O(N)
    static vector<mint> fact;
    static void fact_constructor(const int N){
        fact = vector<mint>(N+1);
        fact[0] =mint(1);
        for(int v:range(1,N+1)) fact[v]=mint(v)*fact[v-1];
    }
    inline mint nPr(const int N,const int r){
        if(r>N)return 0;
        return fact[N]*fact[N-r].minv();
    }
    inline mint nCr(const int N,const int r){
        if(N<0){
            if(0 <= r) return mint(r%2?-1:+1)*nCr(-N +r-1,r);
            else if(r<=N) return mint(((N-r)%2?-1:+1))*nCr(-r-1,N-r);
            else return mint(0);
        }
        if(0<= r && r<=N) return mint(fact[N]) * fact[r].minv() * fact[N-r].minv();
        return mint(0);
    }

    // O(N^2) (no mod N<=66)
    static vector<vector<mint>> C;
    static void C_constructor(const int N){
        C = vector<vector<mint>>(N,vector<mint>(N));
        for(int i:range(N)) C[i][0]=1;
        for(int i :range(1,N))for(int j:range(1,N))
            C[i][j] = C[i-1][j-1]+C[i-1][j];
    }
    static vector<mint> invs;
    static void invs_constructor(int K){
        invs = vector<mint>(K);invs[1] = mint(1);
        for (int i:range(2,K)) invs[i] = invs[mod % i] * (mod - mod / i);
    }
};
vector<mint> mutil::fact,mutil::invs;
vector<vector<mint>> mutil::C;


class Main{
	public:
	void run(){
		mutil mu; mu.C_constructor(100);
		int N,k;cin >> N >> k;

		vector<ll> as(k); cin >> as;
		vector<pair<int,ll>> vs(k);
		for(int i:range(k)) vs[i] = make_pair(__builtin_popcountll(as[i]),as[i]);
		sort(ALL(vs));
		for(int i:range(k-1)){
			if((vs[i].second|vs[i+1].second) >= vs[i+1].second){
				cout << 0 << endl;return;
			}
		}
		vector<int> cs(k+1);
		for(int i:range(k)) cs[i] = vs[i].first;
		cs[k] = N;

		mint res = 1;int ki = 0;
		for(int c:range(1,N)){
			if(cs[ki] == c){
				ki++;
			}else{
				res *= mint(cs[ki] - c + 1);
			}
		}
		cout << res << endl;


		// vector<vector<vector<mint>>> dp(N,vector<vector<mint>>(k+1,vector<mint>(N+1,0)));
		// {
		// 	dp[0][min(k,1)][cs[0]] = 1;
		// 	for(int c:range(cs[0])){
		// 		dp[0][0][c] = mu.C[cs[0]][c];
		// 	}
		// }
		// for(int i:range(1,N)){
		// 	for(int j:range(k+1)){
		// 		for(int c:range(cs[j])){
		// 			for(int prec:range(c)){
		// 				dp[i][j][c] += mu.C[cs[j]-prec][c-prec] * dp[i-1][j][prec];
		// 			}
		// 		}
		// 		if(j >= 1){
		// 			int c = cs[j-1];
		// 			for(int prec:range(c)){
		// 				dp[i][j][c] += dp[i-1][j-1][prec];
		// 			}
		// 		}
		// 	}
		// }
		//
		// mint res = 0;
		// for(int c:range(N+1)) res += dp[N-1][k][c];
		// cout << res << endl;
	}
};

int main(){
	cout <<fixed<<setprecision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);
	Main().run();
	return 0;
}
0