結果
| 問題 |
No.584 赤、緑、青の色塗り
|
| コンテスト | |
| ユーザー |
square1001
|
| 提出日時 | 2018-01-21 17:25:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 441 ms / 2,000 ms |
| コード長 | 1,277 bytes |
| コンパイル時間 | 839 ms |
| コンパイル使用メモリ | 85,588 KB |
| 実行使用メモリ | 31,232 KB |
| 最終ジャッジ日時 | 2024-12-25 21:17:26 |
| 合計ジャッジ時間 | 3,136 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 14 |
ソースコード
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
const int mod = 1000000007;
int N, R, G, B, comb[3009][3009];
int main() {
comb[0][0] = 1;
for (int i = 1; i <= 3000; i++) {
for (int j = 0; j <= i; j++) {
comb[i][j] = comb[i - 1][j];
if (j >= 1) comb[i][j] += comb[i - 1][j - 1];
if (comb[i][j] >= mod) comb[i][j] -= mod;
}
}
cin >> N >> R >> G >> B;
if (R > G) swap(R, G);
if (R > B) swap(R, B);
if (G > B) swap(G, B);
int ret = 0, pw = 1;
for (int two = 0; 2 * two <= R + G + B; two++) {
int one = R + G + B - 2 * two;
if (3 * two + 2 * one >= N + 2) {
pw = 2 * pw % mod;
continue;
}
int res = 0;
for (int i = 0; i <= R; i++) {
for (int j = 0; j <= G; j++) {
int k = 2 * two - i - j;
if (0 <= k && k <= B && two - i >= 0 && two - j >= 0 && two - k >= 0) {
int a = two - i, b = two - j, c = two - k;
res = (res + 1LL * comb[two][a] * comb[two - a][b] % mod * comb[one][R - i] % mod * comb[one - R + i][G - j]) % mod;
}
}
}
ret = (ret + 1LL * res * comb[N + 1 - two * 2 - one][two] % mod * comb[N + 1 - two * 3 - one][one] % mod * pw) % mod;
pw = 2 * pw % mod;
}
cout << ret << endl;
return 0;
}
square1001