結果

問題 No.462 6日知らずのコンピュータ
ユーザー lloyz
提出日時 2023-10-23 22:15:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 81,984 KB
実行使用メモリ 61,976 KB
最終ジャッジ日時 2024-09-22 15:34:52
合計ジャッジ時間 5,493 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
if k > 0:
    A = list(map(int, input().split()))
    A.sort()

mod = 10**9 + 7
Fact = [1]
for i in range(1, n + 1):
    Fact.append(Fact[-1] * i)
ans = 1
L = [0 for _ in range(n)]
for i in range(k):
    NL = [0 for _ in range(n)]
    a = A[i]
    cnt = 0
    for j in range(n):
        NL[j] = a % 2
        a //= 2
        if L[j] == 0 and NL[j] == 1:
            cnt += 1
        elif L[j] == 1 and NL[j] == 0:
            cnt = -1
            break
    if cnt == -1:
        print(0)
        exit()
    ans *= Fact[cnt]
    ans %= mod
    L = NL
NL = [1 for _ in range(n)]
cnt = 0
for i in range(n):
    if L[i] == 0 and NL[i] == 1:
        cnt += 1
ans *= Fact[cnt]
ans %= mod
print(ans)
0