結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-13 02:29:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,288 bytes |
| コンパイル時間 | 1,830 ms |
| コンパイル使用メモリ | 176,980 KB |
| 実行使用メモリ | 6,816 KB |
| 最終ジャッジ日時 | 2024-11-30 00:24:54 |
| 合計ジャッジ時間 | 3,594 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 58 WA * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
const ll mod=1e9+7;
typedef pair<int,ll> P;
inline ll fact(int n)
{
ll ret=1;
for(int i=2; i<=n; ++i) (ret*=i)%=mod;
return ret;
}
inline bool canmove(ll from, ll to)
{
rep(i,63)
{
if(from>>i&1 && !(to>>i&1)) return false;
}
return true;
}
ll solve()
{
int n,k;
scanf(" %d %d", &n, &k);
int ct[61]={};
vector<P> s;
s.pb(P(0,0));
s.pb(P(n,(1LL<<n)-1));
rep(i,k)
{
ll t;
scanf(" %lld", &t);
++ct[__builtin_popcount(t)];
s.pb(P(__builtin_popcount(t),t));
}
if(k==0) return fact(n);
rep(i,61) if(ct[i]>1) return 0;
sort(all(s));
s.erase(unique(all(s)),s.end());
k=s.size();
vector<ll> a(k);
rep(i,k) a[i]=s[i].se;
ll ret=1;
rep(i,k-1)
{
if(!canmove(a[i],a[i+1])) return 0;
(ret*=fact(__builtin_popcount(a[i+1])-__builtin_popcount(a[i])))%=mod;
}
return ret;
}
int main()
{
cout << solve() << endl;
return 0;
}