結果
| 問題 |
No.612 Move on grid
|
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2022-03-28 17:54:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 779 bytes |
| コンパイル時間 | 423 ms |
| コンパイル使用メモリ | 82,560 KB |
| 実行使用メモリ | 272,052 KB |
| 最終ジャッジ日時 | 2024-11-07 09:21:39 |
| 合計ジャッジ時間 | 4,620 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 TLE * 1 |
| other | -- * 17 |
ソースコード
import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
def main():
t = int(input())
a,b,c,d,e = map(int, input().split())
from collections import defaultdict
mod = 10**9+7
dp = defaultdict(lambda: 0)
dp[(0, 0, 0)] = 1
for i in range(t):
ndp = defaultdict(lambda: 0)
for (x, y, z), v in dp.items():
for dx, dy, dz in (-1,0,0),(1,0,0),(0,1,0),(0,-1,0),(0,0,1),(0,0,-1):
nx, ny, nz = x+dx, y+dy, z+dz
ndp[(nx, ny, nz)] += v
ndp[(nx, ny, nz)] += mod
dp = ndp
ans = 0
for (x, y, z), v in dp.items():
if d <= a*x+b*y+c*z <= e:
ans += v
ans %= mod
print(ans)
if __name__ == '__main__':
main()
brthyyjp