結果

問題 No.462 6日知らずのコンピュータ
ユーザー mogurocker
提出日時 2017-10-17 18:01:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 807 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 165,624 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-17 22:28:14
合計ジャッジ時間 4,823 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 75 WA * 3 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n, k;
ll MOD = 1000000007;
bool used[100];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	vector<ll> a(k);
	FOR(i, k) cin >> a[i];
	sort(ALL(a));
	ll ret = 1;
	if (a[k-1] != pow(2, n)-1) a.push_back(pow(2, n)-1);
	FOR(i, a.size()) {
		ll x = a[i], cnt = 0;
		FOR(j, n) {
			if (used[j] && !(x & 1)) ret = 0;
			if (!used[j] && (x & 1)) {
				cnt++;
				used[j] = true;
			}
			x >>= 1;
		}
		while (cnt > 0) {
			ret = ret * cnt % MOD;
			cnt--;
		}
	}
	cout << ret << endl;
	return 0;
}
0