結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
const long long mod=998244353;
const long long hmod=46216567629137;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    cout.tie(0);
    int N;
    cin>>N;
    int L[N],R[N];
    for(int i=0;i<N;i++) cin>>L[i]>>R[i];
    vector<int>per;
    rep(i,N) per.push_back(i);
    int ans=0;
    do{
        bool check=1;
        int diff=0;
        for(int i=0;i<N;i++){
            int now=per[i];
            if(diff>R[now]){
                check=0;
                break;
            }
            if(diff<L[now]) diff=L[now];
        }
        if(check) ans++;
    }while(next_permutation(per.begin(),per.end()));
    cout<<ans<<endl;
}
0