結果
| 問題 |
No.685 Logical Operations
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-01 21:33:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 842 bytes |
| コンパイル時間 | 300 ms |
| コンパイル使用メモリ | 82,788 KB |
| 実行使用メモリ | 76,700 KB |
| 最終ジャッジ日時 | 2024-11-28 13:36:23 |
| 合計ジャッジ時間 | 2,849 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 19 |
ソースコード
import sys
input = lambda : sys.stdin.readline().rstrip()
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))
n = int(input())
l = [
[[0,0,0], [-1, 1, 0]],
[[1,1,0], [0,-1,1]]
]
dp = {}
def sub(y, v1, v3, v4):
if y==0:
return v1 and v3 and v4
elif y<0:
return 0
if (y,v1,v3,v4) in dp:
return dp[y,v1,v3,v4]
res = 0
for i in range(2):
for j in range(2):
ll = l[i][j]
nv1 = v1 + ll[0]
nv3 = v3 + ll[1]
nv4 = v4 + ll[2]
nv1 = max(0, min(1, nv1))
nv3 = max(0, min(1, nv3))
nv4 = max(0, min(1, nv4))
res += sub((y-j)//2, nv1, nv3, nv4)
dp[y,v1,v3,v4] = res
return res
ans = sub(n, 1, 0, 0)
print(ans)