結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| ユーザー |
|
| 提出日時 | 2017-01-25 14:11:19 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 1,123 bytes |
| コンパイル時間 | 78 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-12-23 08:24:12 |
| 合計ジャッジ時間 | 4,605 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 84 |
ソースコード
T = 10 ** 9 + 7
def f(patterns, s1, s2):
import math
count = 0
for s11, s22 in zip(s1, s2):
if s11 == "0" and s22 == "1":
count += 1
elif s11 == "1" and s22 == "0":
patterns = 0
break
return patterns * math.factorial(count) % T
def main():
import sys
n, k = input().split()
n = int(n)
k = int(k)
patterns = 1
if k != 0:
checkpoint = [format(0, "b").zfill(n)] + \
list(map(lambda x: format(x, "b").zfill(n), sorted(list(map(int,input().split()))))) + \
[format(2**n-1,"b").zfill(n)]
else:
checkpoint = [format(0, "b").zfill(n), format(2**n-1, "b").zfill(n)]
for i in range(1, k + 2):
patterns = f(patterns, checkpoint[i-1], checkpoint[i])
print(patterns)
if __name__ == "__main__":
import sys
import os
if len(sys.argv) > 1:
if sys.argv[1] == "-d":
filename = "input1.txt"
fd = os.open(filename, os.O_RDONLY)
os.dup2(fd, sys.stdin.fileno())
main()
else:
main()