結果

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

ソースコード

diff #

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

using ll = int64_t;

ll N;
vector<ll> L, R;

void input() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    L.resize(N), R.resize(N);
    for (ll i=0; i<N; ++i) cin >> L[i] >> R[i];
}

void solve() {
    ll ans = 0;
    vector<ll> p(N);
    for (ll i=0; i<N; ++i) p[i] = i;
    do {
        ll pre = 0;
        bool flg = true;
        for (ll i=0; i<N; ++i) {
            if (R[p[i]] < pre) {
                flg = false;
                break;
            }
            if (L[p[i]] > pre) {
                pre = L[p[i]];
            }
        }
        if (flg) ++ans;
    } while (next_permutation(p.begin(), p.end()));
    cout << ans << "\n";
}

int main() {
    input();
    solve();
    return 0;
}

/* 考察

*/
0