結果

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

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
using ll = long long;
const ll INF32 = 2e9;
const ll INF64 = 4e18;

void printYN(bool ok){
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return;
}

int main() {
    int N;
    cin >> N;
    vector<int> L(N), R(N);
    rep(i, N)cin >> L[i] >> R[i];
    vector<int> P(N);
    rep(i, N)P[i] = i;
    int cnt = 0;
    do {
        bool ok = true;
        int dif = L[P[0]];
        for(int i = 1; i < N; i++){
            if(dif>R[P[i]])ok = false;
            dif = max(dif, L[P[i]]);
        }
        if(ok)cnt++;
    }while(next_permutation(all(P)));
    cout << cnt << endl;
    return 0;
}
0