結果
| 問題 | 
                            No.584 赤、緑、青の色塗り
                             | 
                    
| コンテスト | |
| ユーザー | 
                             norioc
                         | 
                    
| 提出日時 | 2025-04-27 04:29:51 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 990 bytes | 
| コンパイル時間 | 489 ms | 
| コンパイル使用メモリ | 82,312 KB | 
| 実行使用メモリ | 287,556 KB | 
| 最終ジャッジ日時 | 2025-04-27 04:29:56 | 
| 合計ジャッジ時間 | 4,852 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 7 TLE * 1 -- * 6 | 
ソースコード
MOD = 10 ** 9 + 7
N, R, G, B = map(int, input().split())
try:
    import pypyjit
    pypyjit.set_param('max_unroll_recursion=-1')
except ModuleNotFoundError:
    pass
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
    w = (r+g+b) // 2
    if p+r+g+b+w-1 > 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