結果

問題 No.462 6日知らずのコンピュータ
ユーザー ayaoni
提出日時 2020-12-13 03:25:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 988 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 57,984 KB
最終ジャッジ日時 2024-09-19 22:42:09
合計ジャッジ時間 5,746 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,K = MI()
mod = 10**9+7

fac = [1]
for i in range(1,N+1):
    fac.append((fac[-1]*i) % mod)

if K == 0:
    print(fac[N])
    exit()

A = LI()
A.sort()
if A[0] != 0:
    A = [0]+A
if A[-1] != (1<<N)-1:
    A.append((1<<N)-1)

flag = [0]*N
ans = 1
for i in range(len(A)-1):
    c = A[i+1]-A[i]
    r = 0
    for j in range(N):
        if (c>>j) & 1:
            if flag[j]:
                print(0)
                exit()
            else:
                flag[j] = 1
                r += 1
    ans *= fac[r]
    ans %= mod

print(ans)
0