結果

問題 No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
ユーザー bolero
提出日時 2025-08-17 16:27:03
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 721 bytes
コンパイル時間 2,794 ms
コンパイル使用メモリ 280,732 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-18 13:22:39
合計ジャッジ時間 3,649 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    int N;
    cin >> N;

    vector<array<int, 2>> LR(N);
    rep(i, N)
    {
        cin >> LR[i][0] >> LR[i][1];
    }

    vector<int> order(N);
    iota(order.begin(), order.end(), 0);

    int ans = 0;
    do
    {
        int now = -1;
        bool ok = true;
        for (auto i : order)
        {
            auto [L, R] = LR[i];
            if (R < now)
            {
                ok = false;
                break;
            }

            now = max(now, L);
        }

        ans += ok;
    } while (next_permutation(order.begin(), order.end()));

    cout << ans << endl;

    return 0;
}
0