結果
| 問題 |
No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-17 14:52:20 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,015 bytes |
| コンパイル時間 | 2,540 ms |
| コンパイル使用メモリ | 280,928 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-08-18 13:22:40 |
| 合計ジャッジ時間 | 3,536 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
static inline constexpr bool check(const std::vector<std::pair<uint_fast32_t, uint_fast32_t>>& range_of, const std::vector<uint_fast32_t>& p) noexcept
{
uint_fast32_t prev_diff = 0;
for (const auto& cur : p)
{
const auto& [l, r] = range_of[cur];
if (prev_diff > r) return false;
else prev_diff = std::max(prev_diff, l);
}
return true;
}
static inline constexpr uint_fast32_t solve(const uint_fast32_t N, const std::vector<std::pair<uint_fast32_t, uint_fast32_t>>& range_of) noexcept
{
uint_fast32_t ans = 0;
std::vector<uint_fast32_t> p(N);
std::iota(p.begin(), p.end(), 0);
do
{
if (check(range_of, p))
++ans;
}
while (std::next_permutation(p.begin(), p.end()));
return ans;
}
int main()
{
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
uint_fast32_t N;
std::cin >> N;
std::vector<std::pair<uint_fast32_t, uint_fast32_t>> range_of(N);
for (auto& [l, r] : range_of)
std::cin >> l >> r;
std::cout << solve(N, range_of) << '\n';
return 0;
}