結果
問題 | No.122 傾向と対策:門松列(その3) |
ユーザー | kimiyuki |
提出日時 | 2016-12-20 18:20:17 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,755 bytes |
コンパイル時間 | 1,016 ms |
コンパイル使用メモリ | 97,868 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-05-08 08:47:40 |
合計ジャッジ時間 | 6,203 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 591 ms
6,944 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 412 ms
6,940 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <array> #include <set> #include <map> #include <queue> #include <tuple> #include <unordered_set> #include <unordered_map> #include <functional> #include <cassert> #define repeat(i,n) for (int i = 0; (i) < int(n); ++(i)) #define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i)) #define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) typedef long long ll; using namespace std; const int mod = 1e9+7; int main() { const int A = 0, B = 1, C = 2, D = 3, E = 4, F = 5, G = 6; int x_min[7], x_max[7]; repeat (i,7) cin >> x_min[i] >> x_max[i]; auto is_in = [&](int a, int x) { return x_min[x] <= a and a <= x_max[x]; }; auto count_le = [&](int upper, int x) { return max(0, min(upper, x_max[x]) - x_min[x] + 1); }; auto count_ge = [&](int lower, int x) { return max(0, x_max[x] - max(lower, x_min[x]) + 1); }; auto mult_distict = [&](vector<int> ls) { whole(sort, ls); ll acc = 1; repeat (i,ls.size()) acc = acc * max(0, ls[i]-i) % mod; return acc; }; int max_x_max= *whole(max_element, x_max); vector<int> acc_aceg_min(max_x_max+1); repeat(min_aceg, max_x_max+1) { ll acc = 0; if (is_in(min_aceg, A)) acc += mult_distict({ count_ge(min_aceg+1, C), count_ge(min_aceg+1, E), count_ge(min_aceg+1, G) }); if (is_in(min_aceg, C)) acc += mult_distict({ count_ge(min_aceg+1, A), count_ge(min_aceg+1, E), count_ge(min_aceg+1, G) }); if (is_in(min_aceg, E)) acc += mult_distict({ count_ge(min_aceg+1, A), count_ge(min_aceg+1, C), count_ge(min_aceg+1, G) }); if (is_in(min_aceg, G)) acc += mult_distict({ count_ge(min_aceg+1, A), count_ge(min_aceg+1, C), count_ge(min_aceg+1, E) }); acc_aceg_min[min_aceg] = acc % mod; } vector<int> acc_aceg_max(max_x_max+1); repeat (max_aceg, max_x_max+1) { ll acc = 0; if (is_in(max_aceg, A)) acc += mult_distict({ count_le(max_aceg-1, C), count_le(max_aceg-1, E), count_le(max_aceg-1, G) }); if (is_in(max_aceg, C)) acc += mult_distict({ count_le(max_aceg-1, A), count_le(max_aceg-1, E), count_le(max_aceg-1, G) }); if (is_in(max_aceg, E)) acc += mult_distict({ count_le(max_aceg-1, A), count_le(max_aceg-1, C), count_le(max_aceg-1, G) }); if (is_in(max_aceg, G)) acc += mult_distict({ count_le(max_aceg-1, A), count_le(max_aceg-1, C), count_le(max_aceg-1, E) }); acc_aceg_max[max_aceg] = acc % mod; } vector<int> acc_bdf_min(max_x_max+1); repeat (min_bdf, max_x_max+1) { ll acc = 0; if (is_in(min_bdf, B)) acc += mult_distict({ count_ge(min_bdf+1, D), count_ge(min_bdf+1, F) }); if (is_in(min_bdf, D)) acc += mult_distict({ count_ge(min_bdf+1, B), count_ge(min_bdf+1, F) }); if (is_in(min_bdf, F)) acc += mult_distict({ count_ge(min_bdf+1, B), count_ge(min_bdf+1, D) }); acc_bdf_min[min_bdf] = acc % mod; } vector<int> acc_bdf_max(max_x_max+1); repeat (max_bdf, max_x_max+1) { ll acc = 0; if (is_in(max_bdf, B)) acc += mult_distict({ count_le(max_bdf-1, D), count_le(max_bdf-1, F) }); if (is_in(max_bdf, D)) acc += mult_distict({ count_le(max_bdf-1, B), count_le(max_bdf-1, F) }); if (is_in(max_bdf, F)) acc += mult_distict({ count_le(max_bdf-1, B), count_le(max_bdf-1, D) }); acc_bdf_max[max_bdf] = acc % mod; } ll ans = 0; repeat_from (mx,1,max_x_max+1) { repeat_from (mn,mx+1,max_x_max+1) { assert (mx < mn); ans += acc_aceg_max[mx] *(ll) acc_bdf_min[mn] % mod; ans += acc_bdf_max[mx] *(ll) acc_aceg_min[mn] % mod; } ans %= mod; } cout << ans << endl; return 0; }