結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| ユーザー |
|
| 提出日時 | 2017-01-25 14:07:09 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,102 bytes |
| コンパイル時間 | 80 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-12-23 08:24:03 |
| 合計ジャッジ時間 | 5,183 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 54 WA * 30 |
ソースコード
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(int(x), "b").zfill(n), 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()