結果
| 問題 | No.122 傾向と対策:門松列(その3) |
| コンテスト | |
| ユーザー |
T1610
|
| 提出日時 | 2026-09-01 00:16:33 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 151 ms / 5,000 ms |
| + 82µs | |
| コード長 | 1,908 bytes |
| 記録 | |
| コンパイル時間 | 4,125 ms |
| コンパイル使用メモリ | 377,600 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-09-01 00:16:47 |
| 合計ジャッジ時間 | 6,623 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 |
ソースコード
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for (int i = (s); i < (int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for (int i = (int)(s - 1); i >= (int)(e); i--)
#define all(r) r.begin(), r.end()
#define rall(r) r.rbegin(), r.rend()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <typename T, typename U>
T chmax(T& a, const U& b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T, typename U>
T chmin(T& a, const U& b) {
if (a <= b) return false;
a = b;
return true;
}
void yes_no(bool f, string yes = "Yes", string no = "No") { cout << (f ? yes : no) << "\n"; }
void solve() {
const int n = 7;
vi mi(n), ma(n);
rep(i, n) cin >> mi[i] >> ma[i];
using mint = modint1000000007;
mint ans = 0;
vi id(n);
rep(i, n) id[i] = i;
const int sz = *max_element(all(ma)) + 10;
do {
vi rev(n);
rep(i, n) rev[id[i]] = i;
{
int x = min({rev[1], rev[3], rev[5]});
int y = max({rev[1], rev[3], rev[5]});
int a = min({rev[0], rev[2], rev[4], rev[6]});
int b = max({rev[0], rev[2], rev[4], rev[6]});
if (x > b || y < a) {
} else continue;
}
vector<mint> dp(sz);
dp[0] = 1;
for (auto&& i : id) {
vector<mint> nxt(sz);
rep(j, sz - 1) dp[j + 1] += dp[j];
REP(j, mi[i], ma[i] + 1)
nxt[j] += dp[j - 1];
swap(dp, nxt);
}
ans += accumulate(all(dp), mint(0));
} while (next_permutation(all(id)));
cout << ans.val() << "\n";
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int t = 1;
// multi-testcase
// cin >> t;
rep(ti, t) solve();
return 0;
}
T1610