結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-13 00:10:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 820 bytes |
| コンパイル時間 | 1,655 ms |
| コンパイル使用メモリ | 175,404 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-29 18:23:08 |
| 合計ジャッジ時間 | 3,830 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 60 WA * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
int n, k;
cin >> n >> k;
vector<int64_t> a(k);
for (int i = 0; i < k; i++) {
cin >> a[i];
}
sort(a.begin(), a.end(), [](int64_t a, int64_t b) {
return __builtin_popcountll(a) < __builtin_popcountll(b);
});
a.insert(a.begin(), 0);
a.push_back((1LL << n) - 1);
vector<int64_t> fact(100);
fact[0] = 1;
for (int i = 1; i < 100; i++) {
fact[i] = i * fact[i - 1] % mod;
}
int64_t ans = 1;
for (int i = 0; i < a.size() - 1; i++) {
if ((a[i] & a[i + 1]) != a[i]) {
cout << 0 << endl;
return 0;
}
int diff = __builtin_popcountll(a[i] ^ a[i + 1]);
ans *= fact[diff];
}
cout << ans << endl;
}