結果
| 問題 |
No.584 赤、緑、青の色塗り
|
| コンテスト | |
| ユーザー |
nmnmnmnmnmnmnm
|
| 提出日時 | 2017-09-09 16:11:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,630 bytes |
| コンパイル時間 | 800 ms |
| コンパイル使用メモリ | 88,708 KB |
| 実行使用メモリ | 49,792 KB |
| 最終ジャッジ日時 | 2024-11-21 20:46:48 |
| 合計ジャッジ時間 | 4,636 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 RE * 1 |
| other | AC * 7 RE * 7 |
ソースコード
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
#define MOD 1000000007
// 確認用の動的計画法解
// 1<=n<=30,0<=r,g,b<=30 まで対応
ll dp[33][33][33][33][5];
int main() {
ll n,r,g,b;
cin>>n>>r>>g>>b;
clr(dp,0);
dp[0][0][0][0][0] = 1;
dp[0][1][0][0][1] = 1;
dp[0][0][1][0][2] = 1;
dp[0][0][0][1][3] = 1;
rep(i,1,31){
rep(r1,0,31){
rep(g1,0,31){
rep(b1,0,31){
dp[i][r1][g1][b1][0] += dp[i-1][r1][g1][b1][0];
dp[i][r1][g1][b1][0] %= MOD;
dp[i][r1+1][g1][b1][1] += dp[i-1][r1][g1][b1][0];
dp[i][r1+1][g1][b1][1] %= MOD;
dp[i][r1][g1+1][b1][2] += dp[i-1][r1][g1][b1][0];
dp[i][r1][g1+1][b1][2] %= MOD;
dp[i][r1][g1][b1+1][3] += dp[i-1][r1][g1][b1][0];
dp[i][r1][g1][b1+1][3] %= MOD;
dp[i][r1][g1][b1][0] += dp[i-1][r1][g1][b1][1];
dp[i][r1][g1][b1][0] %= MOD;
dp[i][r1][g1][b1][0] += dp[i-1][r1][g1][b1][2];
dp[i][r1][g1][b1][0] %= MOD;
dp[i][r1][g1][b1][0] += dp[i-1][r1][g1][b1][3];
dp[i][r1][g1][b1][0] %= MOD;
dp[i][r1][g1][b1][0] += dp[i-1][r1][g1][b1][4];
dp[i][r1][g1][b1][0] %= MOD;
dp[i][r1+1][g1][b1][4] += dp[i-1][r1][g1][b1][2];
dp[i][r1+1][g1][b1][4] %= MOD;
dp[i][r1+1][g1][b1][4] += dp[i-1][r1][g1][b1][3];
dp[i][r1+1][g1][b1][4] %= MOD;
dp[i][r1][g1+1][b1][4] += dp[i-1][r1][g1][b1][1];
dp[i][r1][g1+1][b1][4] %= MOD;
dp[i][r1][g1+1][b1][4] += dp[i-1][r1][g1][b1][3];
dp[i][r1][g1+1][b1][4] %= MOD;
dp[i][r1][g1][b1+1][4] += dp[i-1][r1][g1][b1][1];
dp[i][r1][g1][b1+1][4] %= MOD;
dp[i][r1][g1][b1+1][4] += dp[i-1][r1][g1][b1][2];
dp[i][r1][g1][b1+1][4] %= MOD;
}
}
}
}
ll ans = 0;
rep(i,0,5){
ans += dp[n-1][r][g][b][i];
ans %= MOD;
}
cout << ans << endl;
return 0;
}
nmnmnmnmnmnmnm