結果

問題 No.462 6日知らずのコンピュータ
コンテスト
ユーザー zelda_master
提出日時 2026-07-26 14:20:28
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.90.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 861 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,065 ms
コンパイル使用メモリ 173,440 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-26 14:20:43
合計ジャッジ時間 4,165 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 27 WA * 57
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef long long LL;

const int N = 70, MOD = 1000000007;

LL a[N];
bool ok;
int n, k, pw[N], ans;

int main() {
    // freopen("computer.in", "r", stdin);
    // freopen("computer.out", "w", stdout);

    scanf("%d%d", &n, &k);
    for (int i = 1; i <= k; ++i) scanf("%lld", &a[i]);

    sort(a + 1, a + n + 1);
    pw[0] = 1;
    for (int i = 1; i <= n; ++i) pw[i] = 1LL * pw[i - 1] * i % MOD;
    a[0] = 0LL, a[k + 1] = (1LL << n) - 1;
    ans = 1, ok = true;
    for (int i = 1; i <= k + 1; ++i) {
        if ((a[i - 1] & a[i]) != a[i - 1]) {
            ok = false;
            break;
        }
        int cnt = __builtin_popcountll(a[i]) - __builtin_popcountll(a[i - 1]);
        ans = 1LL * ans * pw[cnt] % MOD;
    }

    printf("%d\n", ok ? ans : 0);

    return 0;
}
0