結果
| 問題 |
No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
|
| コンテスト | |
| ユーザー |
yesantikiss
|
| 提出日時 | 2025-09-06 13:24:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 3,078 bytes |
| コンパイル時間 | 3,947 ms |
| コンパイル使用メモリ | 253,324 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-06 13:25:00 |
| 合計ジャッジ時間 | 5,080 ms |
|
ジャッジサーバーID (参考情報) |
judge / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define foreach(i, n) for (auto i : (n))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define popcount __builtin_popcountll
using mint = modint998244353;
using mint1 = modint1000000007;
template <typename K, typename V>
using umap = std::unordered_map<K, V>;
template <typename K>
using uset = std::unordered_set<K>;
// 参考元 : https://qiita.com/ganyariya/items/df35d253726269bda436
struct HashPair {
//注意 constがいる
template<class T1, class T2>
size_t operator()(const pair<T1, T2> &p) const {
//first分をハッシュ化する
auto hash1 = hash<T1>{}(p.first);
//second分をハッシュ化する
auto hash2 = hash<T2>{}(p.second);
//重複しないようにハッシュ処理
size_t seed = 0;
seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
return seed;
}
};
template <typename X, typename Y>
using pair_map = unordered_map<pair<X, Y>, ll, HashPair>;
template <typename X, typename Y>
using pair_set = unordered_set<pair<X, Y>, HashPair>;
template <typename T>
using v = vector<T>;
template <typename T>
using vv = v<v<T>>;
template <typename T>
using vvv = vv<v<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using grid = vector<vector<char>>;
using graph = vector<vector<int>>;
using vi = vector<int>; using vvi = vector<vector<int>>; using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>; using vvvl = vector<vector<vector<ll>>>;
using vm = vector<mint>; using vvm = vector<vector<mint>>; using vvvm = vector<vector<vector<mint>>>;
using vm1 = vector<mint1>; using vvm1 = vector<vector<mint1>>; using vvvm1 = vector<vector<vector<mint1>>>;
using vld = vector<ld>; using vvld = vector<vector<ld>>; using vvvld = vector<vector<vector<ld>>>;
using vb = vector<bool>; using vvb = vector<vector<bool>>;
using vs = vector<string>; using vvs = vector<vector<string>>;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
v<P<ll, ll>> a(n);
rep(i, n) cin >> a[i].first >> a[i].second;
ll ans = 0;
vl p(n);
rep(i, n) p[i] = i;
do {
ll now_diff = a[p[0]].first;
bool ok = true;
for (ll i = 1; i < n; i++) {
if (a[p[i]].first <= now_diff && now_diff <= a[p[i]].second) {
continue;
} else if (now_diff < a[p[i]].first) {
now_diff = a[p[i]].first;
} else {
ok = false;
break;
}
}
if (ok) ans++;
} while (next_permutation(ALL(p)));
cout << ans << "\n";
return 0;
}
yesantikiss