結果
| 問題 |
No.584 赤、緑、青の色塗り
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-04-27 04:24:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 826 bytes |
| コンパイル時間 | 571 ms |
| コンパイル使用メモリ | 82,184 KB |
| 実行使用メモリ | 291,312 KB |
| 最終ジャッジ日時 | 2025-04-27 04:24:30 |
| 合計ジャッジ時間 | 5,001 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 7 TLE * 1 -- * 6 |
ソースコード
MOD = 10 ** 9 + 7
N, R, G, B = map(int, input().split())
memo = {}
def f(p, r, g, b):
if (p, r, g, b) in memo: return memo[p, r, g, b]
if p == N or p == N+1:
if r+g+b == 0: return 1
return 0
if p > N:
return 0
res = 0
res += f(p+1, r, g, b)
res %= MOD
if r > 0:
res += f(p+2, r-1, g, b)
res %= MOD
if g > 0:
res += f(p+2, r, g-1, b)
res %= MOD
if b > 0:
res += f(p+2, r, g, b-1)
res %= MOD
if r > 0 and g > 0:
res += 2 * f(p+3, r-1, g-1, b)
res %= MOD
if g > 0 and b > 0:
res += 2 * f(p+3, r, g-1, b-1)
res %= MOD
if r > 0 and b > 0:
res += 2 * f(p+3, r-1, g, b-1)
res %= MOD
memo[p, r, g, b] = res
return res
ans = f(0, R, G, B)
print(ans)
norioc