結果
| 問題 |
No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-06 14:46:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 1,374 bytes |
| コンパイル時間 | 2,355 ms |
| コンパイル使用メモリ | 209,124 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-06 14:46:41 |
| 合計ジャッジ時間 | 3,670 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for(int i=(0+s); i < (n+s); i++)
//pair<T, T>-> P<T>
template<class T> using P = pair<T, T>;
template<class T> struct item {T A, B, C;};
//secondとfirstが交わらないかチェック
vector<vector<ll>> canditates;
vector<bool> visited;
int N;
void dfs(int depth, vector<ll> p){
if(depth==N){
canditates.push_back(p);
return;
}
for(int i=0; i<N; i++){
if(visited[i])continue;
p.push_back(i);
visited[i]=true;
dfs(depth+1, p);
p.pop_back();
visited[i]=false;
}
return;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
visited.resize(N, false);
vector<P<ll>> myvec(N);
rep(i, 0, N) cin >> myvec[i].first >> myvec[i].second;
dfs(0, {});
ll cnt=0;
for(vector<ll> p: canditates){
bool ok=true;
ll min_value=0; //最低限超えていてほしい値
for(int i=0; i<N-1; i++)
{
if(myvec[p[i]].first>myvec[p[i+1]].second || myvec[p[i+1]].second<min_value){ok=false;break;}
min_value=max(min_value, myvec[p[i]].first);
}
if(ok){
cnt++;
// for(ll a : p)cout << a;
// cout << endl;
}
}
cout << cnt << endl;
return 0;
}