結果

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

ソースコード

diff #

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

#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << "\n"
#else
#define debug(x) void(0)
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
	for (int i = 0; i < (int)v.size(); i++)
		os << v[i] << (i + 1 == (int)v.size() ? "" : " ");
	return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
	for (int i = 0; i < (int)v.size(); i++)
		is >> v[i];
	return is;
}

////////////////////////////////////////////////////////////

int main()
{
	int N;
	cin >> N;
	vector<int> L(N), R(N);
	for (int i = 0; i < N; i++)
		cin >> L[i] >> R[i];
	vector<int> idx(N);
	iota(idx.begin(), idx.end(), 0);
	int ans = 0;
	do
	{
		bool ok = true;
		int cur = 0;
		for (int i = 0; i < N; i++)
		{
			if (cur > R[idx[i]])
			{
				ok = false;
				break;
			}
			cur = max(cur, L[idx[i]]);
		}
		ans += ok;
	} while (next_permutation(idx.begin(), idx.end()));
	cout << ans << "\n";
	return 0;
}
0