結果
問題 | No.1532 Different Products |
ユーザー | keijak |
提出日時 | 2021-06-04 22:26:44 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,628 bytes |
コンパイル時間 | 7,885 ms |
コンパイル使用メモリ | 400,112 KB |
実行使用メモリ | 906,360 KB |
最終ジャッジ日時 | 2024-11-19 21:27:33 |
合計ジャッジ時間 | 219,830 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
70,016 KB |
testcase_01 | AC | 1,025 ms
450,096 KB |
testcase_02 | AC | 37 ms
70,016 KB |
testcase_03 | AC | 37 ms
71,732 KB |
testcase_04 | AC | 36 ms
70,016 KB |
testcase_05 | AC | 36 ms
313,840 KB |
testcase_06 | AC | 36 ms
70,016 KB |
testcase_07 | AC | 37 ms
387,476 KB |
testcase_08 | AC | 36 ms
70,144 KB |
testcase_09 | AC | 52 ms
71,700 KB |
testcase_10 | AC | 821 ms
109,992 KB |
testcase_11 | AC | 444 ms
415,852 KB |
testcase_12 | TLE | - |
testcase_13 | AC | 1,035 ms
136,524 KB |
testcase_14 | TLE | - |
testcase_15 | AC | 38 ms
387,692 KB |
testcase_16 | AC | 2,434 ms
205,424 KB |
testcase_17 | AC | 374 ms
72,928 KB |
testcase_18 | AC | 127 ms
70,252 KB |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | MLE | - |
testcase_22 | AC | 1,624 ms
144,360 KB |
testcase_23 | AC | 180 ms
71,696 KB |
testcase_24 | MLE | - |
testcase_25 | TLE | - |
testcase_26 | AC | 139 ms
387,804 KB |
testcase_27 | TLE | - |
testcase_28 | MLE | - |
testcase_29 | MLE | - |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
testcase_32 | TLE | - |
testcase_33 | MLE | - |
testcase_34 | MLE | - |
testcase_35 | TLE | - |
testcase_36 | MLE | - |
testcase_37 | AC | 1,504 ms
146,028 KB |
testcase_38 | TLE | - |
testcase_39 | TLE | - |
testcase_40 | MLE | - |
testcase_41 | TLE | - |
testcase_42 | MLE | - |
testcase_43 | TLE | - |
testcase_44 | TLE | - |
testcase_45 | TLE | - |
testcase_46 | TLE | - |
testcase_47 | TLE | - |
testcase_48 | TLE | - |
testcase_49 | MLE | - |
testcase_50 | TLE | - |
testcase_51 | MLE | - |
testcase_52 | TLE | - |
testcase_53 | TLE | - |
testcase_54 | MLE | - |
testcase_55 | TLE | - |
testcase_56 | TLE | - |
testcase_57 | TLE | - |
testcase_58 | TLE | - |
testcase_59 | MLE | - |
testcase_60 | TLE | - |
testcase_61 | AC | 38 ms
71,696 KB |
testcase_62 | AC | 40 ms
64,632 KB |
testcase_63 | MLE | - |
ソースコード
#include <bits/stdc++.h> #define REP_(i, a_, b_, a, b, ...) \ for (int i = (a), END_##i = (b); i < END_##i; ++i) #define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__) #define ALL(x) std::begin(x), std::end(x) using i64 = long long; #include <boost/multiprecision/cpp_int.hpp> using Int = boost::multiprecision::checked_int128_t; // using i256 = boost::multiprecision::int256_t; // using i512 = boost::multiprecision::int512_t; // using i1024 = boost::multiprecision::int1024_t; // using Int = boost::multiprecision::cpp_int; template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b and ((a = std::move(b)), true); } template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b and ((a = std::move(b)), true); } template <typename T> inline int ssize(const T &a) { return (int)std::size(a); } template <typename T> std::istream &operator>>(std::istream &is, std::vector<T> &a) { for (auto &x : a) is >> x; return is; } template <typename T, typename U> std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &a) { return os << "(" << a.first << ", " << a.second << ")"; } template <typename Container> std::ostream &print_seq(const Container &a, std::string_view sep = " ", std::string_view ends = "\n", std::ostream &os = std::cout) { auto b = std::begin(a), e = std::end(a); for (auto it = std::begin(a); it != e; ++it) { if (it != b) os << sep; os << *it; } return os << ends; } template <typename T, typename = void> struct is_iterable : std::false_type {}; template <typename T> struct is_iterable<T, std::void_t<decltype(std::begin(std::declval<T>())), decltype(std::end(std::declval<T>()))>> : std::true_type {}; template <typename T, typename = std::enable_if_t< is_iterable<T>::value && !std::is_same<T, std::string_view>::value && !std::is_same<T, std::string>::value>> std::ostream &operator<<(std::ostream &os, const T &a) { return print_seq(a, ", ", "", (os << "{")) << "}"; } #ifdef ENABLE_DEBUG #include "debug_dump.hpp" #else #define DUMP(...) #endif using namespace std; #include <ext/pb_ds/assoc_container.hpp> template <class K, class V> using gp_hash_table = __gnu_pbds::gp_hash_table< K, V, std::hash<K>, std::equal_to<K>, __gnu_pbds::direct_mask_range_hashing<K>, __gnu_pbds::linear_probe_fn<>, __gnu_pbds::hash_standard_resize_policy< __gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<true>, true>>; std::mt19937_64 &PRNG() { static std::random_device seed_gen; static std::mt19937_64 engine(seed_gen()); // non-deterministic return engine; } auto solve() { i64 n, K; cin >> n >> K; vector<int> va, vb; for (int i = 2; i <= n; ++i) { va.push_back(i); } shuffle(ALL(va), PRNG()); REP(i, n / 2) { vb.push_back(va.back()); va.pop_back(); } sort(ALL(va), greater{}); sort(ALL(vb), greater{}); DUMP(va, vb); auto f = [&](auto &f, const vector<int> &v, int i, i64 acc, gp_hash_table<i64, i64> &mp) -> void { const int m = ssize(v); if (i == m) { return; } f(f, v, i + 1, acc, mp); acc *= v[i]; if (acc <= K) { ++mp[acc]; f(f, v, i + 1, acc, mp); } }; gp_hash_table<i64, i64> ma, mb; // ma.reserve(1 << 20); // ma.max_load_factor(0.25); // mb.reserve(1 << 20); // mb.max_load_factor(0.25); ma.resize(1 << 20); mb.resize(1 << 20); ma[1] = 1; mb[1] = 1; f(f, va, 0, 1, ma); cerr << "ma:" << ssize(ma) << endl; f(f, vb, 0, 1, mb); DUMP(ma); DUMP(mb); cerr << "mb:" << ssize(mb) << endl; vector<pair<i64, i64>> ca(ssize(ma) + 1), cb(ssize(mb)); { int i = 0; for (auto [k, v] : ma) { ++i; ca[i] = {k, v}; // ca[i].second += ca[i - 1].second; } sort(ALL(ca)); REP(j, 1, ssize(ca)) { ca[j].second += ca[j - 1].second; } i = 0; for (auto [k, v] : mb) { cb[i] = {k, v}; ++i; // cb[i].second += cb[i - 1].second; } sort(ALL(cb), greater{}); } ca.emplace_back(K + 1, 0); DUMP(ca); DUMP(cb); i64 ans = 0; { int i = 1; for (const auto &[x2, k2] : cb) { while (i < ssize(ca) and ca[i].first * x2 <= K) { ++i; } ans += k2 * ca[i - 1].second; DUMP(x2, k2, ca[i - 1].second, ans); } } ans *= 2; return ans - 1; } int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); cout << solve() << "\n"; }