結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
#define all(a) (a).begin(),(a).end()

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<int> L(N), R(N);
    rep(i, 0, N) cin >> L[i] >> R[i];
    
    vector<int> P(N);
    rep(i, 0, N) P[i] = i;
    
    int ans = 0;
    do {
        int t = 0;
        bool can = true;
        rep(i, 0, N) {
            if (R[P[i]] < t) can = false;
            else t = max(t, L[P[i]]);
        }
        
        if (can) ++ans;
        
    } while (next_permutation(all(P)));
    
    cout << ans << '\n';
}
0