cleanup
This commit is contained in:
parent
9a0bd51ac8
commit
7db2259486
19 changed files with 1 additions and 1500 deletions
|
|
@ -1,76 +0,0 @@
|
|||
#include <bits/stdc++.h> // {{{
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
using i32 = int32_t;
|
||||
using u32 = uint32_t;
|
||||
using i64 = int64_t;
|
||||
using u64 = uint64_t;
|
||||
using f64 = double;
|
||||
using f128 = long double;
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template <typename T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
static void NO() {
|
||||
std::cout << "NO\n";
|
||||
}
|
||||
|
||||
static void YES() {
|
||||
std::cout << "YES\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
#define ff first
|
||||
#define ss second
|
||||
|
||||
#ifdef LOCAL
|
||||
#define db(...) std::print(__VA_ARGS__)
|
||||
#define dbln(...) std::println(__VA_ARGS__)
|
||||
#else
|
||||
#define db(...)
|
||||
#define dbln(...)
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
cin.exceptions(cin.failbit);
|
||||
|
||||
u32 tc = 1;
|
||||
cin >> tc;
|
||||
|
||||
for (u32 t = 0; t < tc; ++t) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
#include <bits/stdc++.h> // {{{
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
using i32 = int32_t;
|
||||
using u32 = uint32_t;
|
||||
using i64 = int64_t;
|
||||
using u64 = uint64_t;
|
||||
using f64 = double;
|
||||
using f128 = long double;
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template <typename T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
static void NO() {
|
||||
std::cout << "NO\n";
|
||||
}
|
||||
|
||||
static void YES() {
|
||||
std::cout << "YES\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
#define ff first
|
||||
#define ss second
|
||||
|
||||
#ifdef LOCAL
|
||||
#define db(...) std::print(__VA_ARGS__)
|
||||
#define dbln(...) std::println(__VA_ARGS__)
|
||||
#else
|
||||
#define db(...)
|
||||
#define dbln(...)
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
#include <bits/stdc++.h> // {{{
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
using i32 = int32_t;
|
||||
using u32 = uint32_t;
|
||||
using i64 = int64_t;
|
||||
using u64 = uint64_t;
|
||||
using f64 = double;
|
||||
using f128 = long double;
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template <typename T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
static void NO() {
|
||||
std::cout << "NO\n";
|
||||
}
|
||||
|
||||
static void YES() {
|
||||
std::cout << "YES\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
#define ff first
|
||||
#define ss second
|
||||
|
||||
#ifdef LOCAL
|
||||
#define db(...) std::print(__VA_ARGS__)
|
||||
#define dbln(...) std::println(__VA_ARGS__)
|
||||
#else
|
||||
#define db(...)
|
||||
#define dbln(...)
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
cin.exceptions(cin.failbit);
|
||||
|
||||
u32 tc = 1;
|
||||
cin >> tc;
|
||||
|
||||
for (u32 t = 0; t < tc; ++t) {
|
||||
solve();
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
#include <bits/stdc++.h> // {{{
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
using i32 = int32_t;
|
||||
using u32 = uint32_t;
|
||||
using i64 = int64_t;
|
||||
using u64 = uint64_t;
|
||||
using f64 = double;
|
||||
using f128 = long double;
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template <typename T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
static void NO() {
|
||||
std::cout << "NO\n";
|
||||
}
|
||||
|
||||
static void YES() {
|
||||
std::cout << "YES\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
#define ff first
|
||||
#define ss second
|
||||
|
||||
#ifdef LOCAL
|
||||
#define db(...) std::print(__VA_ARGS__)
|
||||
#define dbln(...) std::println(__VA_ARGS__)
|
||||
#else
|
||||
#define db(...)
|
||||
#define dbln(...)
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
#include <bits/stdc++.h> // {{{
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
using i32 = int32_t;
|
||||
using u32 = uint32_t;
|
||||
using i64 = int64_t;
|
||||
using u64 = uint64_t;
|
||||
using f64 = double;
|
||||
using f128 = long double;
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template <typename T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
static void NO() {
|
||||
std::cout << "NO\n";
|
||||
}
|
||||
|
||||
static void YES() {
|
||||
std::cout << "YES\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
#define ff first
|
||||
#define ss second
|
||||
|
||||
#ifdef LOCAL
|
||||
#define db(...) std::print(__VA_ARGS__)
|
||||
#define dbln(...) std::println(__VA_ARGS__)
|
||||
#else
|
||||
#define db(...)
|
||||
#define dbln(...)
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
cin.exceptions(cin.failbit);
|
||||
|
||||
u32 tc = 1;
|
||||
cin >> tc;
|
||||
|
||||
for (u32 t = 0; t < tc; ++t) {
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
#include <bits/stdc++.h> // {{{
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
using i32 = int32_t;
|
||||
using u32 = uint32_t;
|
||||
using i64 = int64_t;
|
||||
using u64 = uint64_t;
|
||||
using f64 = double;
|
||||
using f128 = long double;
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template <typename T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
static void NO() {
|
||||
std::cout << "NO\n";
|
||||
}
|
||||
|
||||
static void YES() {
|
||||
std::cout << "YES\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
#define ff first
|
||||
#define ss second
|
||||
|
||||
#ifdef LOCAL
|
||||
#define db(...) std::print(__VA_ARGS__)
|
||||
#define dbln(...) std::println(__VA_ARGS__)
|
||||
#else
|
||||
#define db(...)
|
||||
#define dbln(...)
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
#include <bits/stdc++.h> // {{{
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
using i32 = int32_t;
|
||||
using u32 = uint32_t;
|
||||
using i64 = int64_t;
|
||||
using u64 = uint64_t;
|
||||
using f64 = double;
|
||||
using f128 = long double;
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template <typename T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
static void NO() {
|
||||
std::cout << "NO\n";
|
||||
}
|
||||
|
||||
static void YES() {
|
||||
std::cout << "YES\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
#define ff first
|
||||
#define ss second
|
||||
|
||||
#ifdef LOCAL
|
||||
#define db(...) std::print(__VA_ARGS__)
|
||||
#define dbln(...) std::println(__VA_ARGS__)
|
||||
#else
|
||||
#define db(...)
|
||||
#define dbln(...)
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
|
|
@ -1 +0,0 @@
|
|||
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
#include <bits/stdc++.h> // {{{
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
using i32 = int32_t;
|
||||
using u32 = uint32_t;
|
||||
using i64 = int64_t;
|
||||
using u64 = uint64_t;
|
||||
using f64 = double;
|
||||
using f128 = long double;
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template <typename T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
static void NO() {
|
||||
std::cout << "NO\n";
|
||||
}
|
||||
|
||||
static void YES() {
|
||||
std::cout << "YES\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
#define ff first
|
||||
#define ss second
|
||||
|
||||
#ifdef LOCAL
|
||||
#define db(...) std::print(__VA_ARGS__)
|
||||
#define dbln(...) std::println(__VA_ARGS__)
|
||||
#else
|
||||
#define db(...)
|
||||
#define dbln(...)
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
cin.exceptions(cin.failbit);
|
||||
|
||||
u32 tc = 1;
|
||||
cin >> tc;
|
||||
|
||||
for (u32 t = 0; t < tc; ++t) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
#include <bits/stdc++.h> // {{{
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
using i32 = int32_t;
|
||||
using u32 = uint32_t;
|
||||
using i64 = int64_t;
|
||||
using u64 = uint64_t;
|
||||
using f64 = double;
|
||||
using f128 = long double;
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
template <typename T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
static void NO() {
|
||||
std::cout << "NO\n";
|
||||
}
|
||||
|
||||
static void YES() {
|
||||
std::cout << "YES\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
#define ff first
|
||||
#define ss second
|
||||
|
||||
#ifdef LOCAL
|
||||
#define db(...) std::print(__VA_ARGS__)
|
||||
#define dbln(...) std::println(__VA_ARGS__)
|
||||
#else
|
||||
#define db(...)
|
||||
#define dbln(...)
|
||||
#endif
|
||||
// }}}
|
||||
|
|
@ -1 +0,0 @@
|
|||
#include <bits/stdc++.h>
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
#include <bits/stdc++.h>
|
||||
#include <ext/pb_ds/assoc_container.hpp>
|
||||
#include <ext/pb_ds/tree_policy.hpp>
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
using namespace __gnu_pbds;
|
||||
|
||||
// https://mirror.codeforces.com/blog/entry/124683
|
||||
|
||||
namespace hashing {
|
||||
using i64 = std::int64_t;
|
||||
using u64 = std::uint64_t;
|
||||
static const u64 FIXED_RANDOM =
|
||||
std::chrono::steady_clock::now().time_since_epoch().count();
|
||||
|
||||
#if USE_AES
|
||||
std::mt19937 rd(FIXED_RANDOM);
|
||||
const __m128i KEY1{(i64)rd(), (i64)rd()};
|
||||
const __m128i KEY2{(i64)rd(), (i64)rd()};
|
||||
#endif
|
||||
|
||||
template <class T, class D = void> struct custom_hash {};
|
||||
|
||||
template <class T> inline void hash_combine(u64 &seed, T const &v) {
|
||||
custom_hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T,
|
||||
typename std::enable_if<std::is_integral<T>::value>::type> {
|
||||
u64 operator()(T _x) const {
|
||||
u64 x = _x;
|
||||
#if USE_AES
|
||||
__m128i m{i64(u64(x) * 0xbf58476d1ce4e5b9u64), (i64)FIXED_RANDOM};
|
||||
__m128i y = _mm_aesenc_si128(m, KEY1);
|
||||
__m128i z = _mm_aesenc_si128(y, KEY2);
|
||||
return z[0];
|
||||
#else
|
||||
x += 0x9e3779b97f4a7c15 + FIXED_RANDOM;
|
||||
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
|
||||
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
|
||||
return x ^ (x >> 31);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T, std::void_t<decltype(std::begin(std::declval<T>()))>> {
|
||||
u64 operator()(T const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
for (auto &x : a)
|
||||
hash_combine(value, x);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class... T> struct custom_hash<std::tuple<T...>> {
|
||||
u64 operator()(const std::tuple<T...> &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
std::apply([&value](T const &...args) { (hash_combine(value, args), ...); },
|
||||
a);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class U> struct custom_hash<std::pair<T, U>> {
|
||||
u64 operator()(std::pair<T, U> const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
hash_combine(value, a.first);
|
||||
hash_combine(value, a.second);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}; // namespace hashing
|
||||
|
||||
#ifdef PB_DS_ASSOC_CNTNR_HPP
|
||||
template <class Key, class Value>
|
||||
using hashmap = gp_hash_table<
|
||||
Key, Value, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
template <class Key>
|
||||
using hashset = gp_hash_table<
|
||||
Key, null_type, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_POLICY_HPP
|
||||
template <typename T>
|
||||
using multiset = tree<T, null_type, std::less_equal<T>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
template <class Key, class Value = null_type>
|
||||
using rbtree = tree<Key, Value, std::less<Key>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
#endif
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define ll long long
|
||||
#define vec vector
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (r).rbegin(), (x).rend()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
#define FOR(a, b, c) for (int a = b; a < c; ++a)
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
template <typename... Args> void print(string const &str, Args &&...args) {
|
||||
cout << vformat(str, make_format_args(forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <typename T> void print(T const &t) { cout << t; }
|
||||
|
||||
template <ranges::range T> void print(T const &t) {
|
||||
if constexpr (is_same_v<T, string> || is_convertible_v<T, char const *>) {
|
||||
cout << t << '\n';
|
||||
} else {
|
||||
for (const auto &e : t) {
|
||||
cout << e << ' ';
|
||||
}
|
||||
cout << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args> void println(string const &str, Args &&...args) {
|
||||
print(str, fo
|
||||
|
|
@ -1,193 +0,0 @@
|
|||
#include <bits/stdc++.h>
|
||||
#include <ext/pb_ds/assoc_container.hpp>
|
||||
#include <ext/pb_ds/tree_policy.hpp>
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
using namespace __gnu_pbds;
|
||||
|
||||
// https://mirror.codeforces.com/blog/entry/124683
|
||||
|
||||
namespace hashing {
|
||||
using i64 = std::int64_t;
|
||||
using u64 = std::uint64_t;
|
||||
static const u64 FIXED_RANDOM =
|
||||
std::chrono::steady_clock::now().time_since_epoch().count();
|
||||
|
||||
#if USE_AES
|
||||
std::mt19937 rd(FIXED_RANDOM);
|
||||
const __m128i KEY1{(i64)rd(), (i64)rd()};
|
||||
const __m128i KEY2{(i64)rd(), (i64)rd()};
|
||||
#endif
|
||||
|
||||
template <class T, class D = void> struct custom_hash {};
|
||||
|
||||
template <class T> inline void hash_combine(u64 &seed, T const &v) {
|
||||
custom_hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T,
|
||||
typename std::enable_if<std::is_integral<T>::value>::type> {
|
||||
u64 operator()(T _x) const {
|
||||
u64 x = _x;
|
||||
#if USE_AES
|
||||
__m128i m{i64(u64(x) * 0xbf58476d1ce4e5b9u64), (i64)FIXED_RANDOM};
|
||||
__m128i y = _mm_aesenc_si128(m, KEY1);
|
||||
__m128i z = _mm_aesenc_si128(y, KEY2);
|
||||
return z[0];
|
||||
#else
|
||||
x += 0x9e3779b97f4a7c15 + FIXED_RANDOM;
|
||||
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
|
||||
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
|
||||
return x ^ (x >> 31);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T, std::void_t<decltype(std::begin(std::declval<T>()))>> {
|
||||
u64 operator()(T const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
for (auto &x : a)
|
||||
hash_combine(value, x);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class... T> struct custom_hash<std::tuple<T...>> {
|
||||
u64 operator()(const std::tuple<T...> &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
std::apply([&value](T const &...args) { (hash_combine(value, args), ...); },
|
||||
a);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class U> struct custom_hash<std::pair<T, U>> {
|
||||
u64 operator()(std::pair<T, U> const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
hash_combine(value, a.first);
|
||||
hash_combine(value, a.second);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}; // namespace hashing
|
||||
|
||||
#ifdef PB_DS_ASSOC_CNTNR_HPP
|
||||
template <class Key, class Value>
|
||||
using hashmap = gp_hash_table<
|
||||
Key, Value, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
template <class Key>
|
||||
using hashset = gp_hash_table<
|
||||
Key, null_type, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_POLICY_HPP
|
||||
template <typename T>
|
||||
using multiset = tree<T, null_type, std::less_equal<T>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
template <class Key, class Value = null_type>
|
||||
using rbtree = tree<Key, Value, std::less<Key>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
#endif
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define ll long long
|
||||
#define vec vector
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (r).rbegin(), (x).rend()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
#define FOR(a, b, c) for (int a = b; a < c; ++a)
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
template <typename... Args> void print(string const &str, Args &&...args) {
|
||||
cout << vformat(str, make_format_args(forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <typename T> void print(T const &t) { cout << t; }
|
||||
|
||||
template <ranges::range T> void print(T const &t) {
|
||||
if constexpr (is_same_v<T, string> || is_convertible_v<T, char const *>) {
|
||||
cout << t << '\n';
|
||||
} else {
|
||||
for (const auto &e : t) {
|
||||
cout << e << ' ';
|
||||
}
|
||||
cout << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args> void println(string const &str, Args &&...args) {
|
||||
print(str, forward<Args>(args)...);
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T> void println(T const &t) { print("{}\n", t); }
|
||||
|
||||
template <ranges::range T> void println(T const &t) {
|
||||
print(t);
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
void println() { cout << '\n'; }
|
||||
|
||||
template <typename T> T max() { return numeric_limits<T>::max(); }
|
||||
|
||||
template <typename T> T min() { return numeric_limits<T>::min(); }
|
||||
|
||||
constexpr static int MOD = 1e9 + 7;
|
||||
|
||||
void solve() {
|
||||
int n, k, d;
|
||||
cin >> n >> k >> d;
|
||||
hashmap<pair<int, int>, int> memo;
|
||||
|
||||
auto dp = [&](auto &self, int n, int d) -> int {
|
||||
if (memo.find({n, d}) != memo.end())
|
||||
return memo[{n, d}];
|
||||
|
||||
if (n == 0)
|
||||
return d == 0 ? 1 : 0;
|
||||
|
||||
ll total = 0;
|
||||
|
||||
FOR(i, 1, min(n + 1, k + 1)) {
|
||||
total = (total + self(self, n - i, i < d ? d : 0)) % MOD;
|
||||
}
|
||||
|
||||
return memo[{n, d}] = total;
|
||||
};
|
||||
|
||||
print(dp(dp, n, d));
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
// cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,193 +0,0 @@
|
|||
#include <bits/stdc++.h>
|
||||
#include <ext/pb_ds/assoc_container.hpp>
|
||||
#include <ext/pb_ds/tree_policy.hpp>
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
using namespace __gnu_pbds;
|
||||
|
||||
// https://mirror.codeforces.com/blog/entry/124683
|
||||
|
||||
namespace hashing {
|
||||
using i64 = std::int64_t;
|
||||
using u64 = std::uint64_t;
|
||||
static const u64 FIXED_RANDOM =
|
||||
std::chrono::steady_clock::now().time_since_epoch().count();
|
||||
|
||||
#if USE_AES
|
||||
std::mt19937 rd(FIXED_RANDOM);
|
||||
const __m128i KEY1{(i64)rd(), (i64)rd()};
|
||||
const __m128i KEY2{(i64)rd(), (i64)rd()};
|
||||
#endif
|
||||
|
||||
template <class T, class D = void> struct custom_hash {};
|
||||
|
||||
template <class T> inline void hash_combine(u64 &seed, T const &v) {
|
||||
custom_hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T,
|
||||
typename std::enable_if<std::is_integral<T>::value>::type> {
|
||||
u64 operator()(T _x) const {
|
||||
u64 x = _x;
|
||||
#if USE_AES
|
||||
__m128i m{i64(u64(x) * 0xbf58476d1ce4e5b9u64), (i64)FIXED_RANDOM};
|
||||
__m128i y = _mm_aesenc_si128(m, KEY1);
|
||||
__m128i z = _mm_aesenc_si128(y, KEY2);
|
||||
return z[0];
|
||||
#else
|
||||
x += 0x9e3779b97f4a7c15 + FIXED_RANDOM;
|
||||
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
|
||||
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
|
||||
return x ^ (x >> 31);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T, std::void_t<decltype(std::begin(std::declval<T>()))>> {
|
||||
u64 operator()(T const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
for (auto &x : a)
|
||||
hash_combine(value, x);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class... T> struct custom_hash<std::tuple<T...>> {
|
||||
u64 operator()(const std::tuple<T...> &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
std::apply([&value](T const &...args) { (hash_combine(value, args), ...); },
|
||||
a);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class U> struct custom_hash<std::pair<T, U>> {
|
||||
u64 operator()(std::pair<T, U> const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
hash_combine(value, a.first);
|
||||
hash_combine(value, a.second);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}; // namespace hashing
|
||||
|
||||
#ifdef PB_DS_ASSOC_CNTNR_HPP
|
||||
template <class Key, class Value>
|
||||
using hashmap = gp_hash_table<
|
||||
Key, Value, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
template <class Key>
|
||||
using hashset = gp_hash_table<
|
||||
Key, null_type, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_POLICY_HPP
|
||||
template <typename T>
|
||||
using multiset = tree<T, null_type, std::less_equal<T>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
template <class Key, class Value = null_type>
|
||||
using rbtree = tree<Key, Value, std::less<Key>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
#endif
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define ll long long
|
||||
#define vec vector
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (r).rbegin(), (x).rend()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
#define FOR(a, b, c) for (int a = b; a < c; ++a)
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
template <typename... Args> void print(string const &str, Args &&...args) {
|
||||
cout << vformat(str, make_format_args(forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <typename T> void print(T const &t) { cout << t; }
|
||||
|
||||
template <ranges::range T> void print(T const &t) {
|
||||
if constexpr (is_same_v<T, string> || is_convertible_v<T, char const *>) {
|
||||
cout << t << '\n';
|
||||
} else {
|
||||
for (const auto &e : t) {
|
||||
cout << e << ' ';
|
||||
}
|
||||
cout << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args> void println(string const &str, Args &&...args) {
|
||||
print(str, forward<Args>(args)...);
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T> void println(T const &t) { print("{}\n", t); }
|
||||
|
||||
template <ranges::range T> void println(T const &t) {
|
||||
print(t);
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
void println() { cout << '\n'; }
|
||||
|
||||
template <typename T> T max() { return numeric_limits<T>::max(); }
|
||||
|
||||
template <typename T> T min() { return numeric_limits<T>::min(); }
|
||||
|
||||
constexpr static int MOD = 1e9 + 7;
|
||||
|
||||
void solve() {
|
||||
int n, k, d;
|
||||
cin >> n >> k >> d;
|
||||
hashmap<pair<int, int>, int> memo;
|
||||
|
||||
auto dp = [&](auto &self, int n, int d) -> int {
|
||||
if (memo.find({n, d}) != memo.end())
|
||||
return memo[{n, d}];
|
||||
|
||||
if (n == 0)
|
||||
return d == 0 ? 1 : 0;
|
||||
|
||||
ll total = 0;
|
||||
|
||||
FOR(i, 1, min(n + 1, k + 1)) {
|
||||
total = (total + self(self, n - i, i < d ? d : 0)) % MOD;
|
||||
}
|
||||
|
||||
return memo[{n, d}] = total;
|
||||
};
|
||||
|
||||
print(dp(dp, n, d));
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
// cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
#include <bits/stdc++.h>
|
||||
#include <ext/pb_ds/assoc_container.hpp>
|
||||
#include <ext/pb_ds/tree_policy.hpp>
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
using namespace __gnu_pbds;
|
||||
|
||||
// https://mirror.codeforces.com/blog/entry/124683
|
||||
|
||||
namespace hashing {
|
||||
using i64 = std::int64_t;
|
||||
using u64 = std::uint64_t;
|
||||
static const u64 FIXED_RANDOM =
|
||||
std::chrono::steady_clock::now().time_since_epoch().count();
|
||||
|
||||
#if USE_AES
|
||||
std::mt19937 rd(FIXED_RANDOM);
|
||||
const __m128i KEY1{(i64)rd(), (i64)rd()};
|
||||
const __m128i KEY2{(i64)rd(), (i64)rd()};
|
||||
#endif
|
||||
|
||||
template <class T, class D = void> struct custom_hash {};
|
||||
|
||||
template <class T> inline void hash_combine(u64 &seed, T const &v) {
|
||||
custom_hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T,
|
||||
typename std::enable_if<std::is_integral<T>::value>::type> {
|
||||
u64 operator()(T _x) const {
|
||||
u64 x = _x;
|
||||
#if USE_AES
|
||||
__m128i m{i64(u64(x) * 0xbf58476d1ce4e5b9u64), (i64)FIXED_RANDOM};
|
||||
__m128i y = _mm_aesenc_si128(m, KEY1);
|
||||
__m128i z = _mm_aesenc_si128(y, KEY2);
|
||||
return z[0];
|
||||
#else
|
||||
x += 0x9e3779b97f4a7c15 + FIXED_RANDOM;
|
||||
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
|
||||
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
|
||||
return x ^ (x >> 31);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T, std::void_t<decltype(std::begin(std::declval<T>()))>> {
|
||||
u64 operator()(T const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
for (auto &x : a)
|
||||
hash_combine(value, x);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class... T> struct custom_hash<std::tuple<T...>> {
|
||||
u64 operator()(const std::tuple<T...> &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
std::apply([&value](T const &...args) { (hash_combine(value, args), ...); },
|
||||
a);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class U> struct custom_hash<std::pair<T, U>> {
|
||||
u64 operator()(std::pair<T, U> const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
hash_combine(value, a.first);
|
||||
hash_combine(value, a.second);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}; // namespace hashing
|
||||
|
||||
#ifdef PB_DS_ASSOC_CNTNR_HPP
|
||||
template <class Key, class Value>
|
||||
using hashmap = gp_hash_table<
|
||||
Key, Value, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
template <class Key>
|
||||
using hashset = gp_hash_table<
|
||||
Key, null_type, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_POLICY_HPP
|
||||
template <typename T>
|
||||
using multiset = tree<T, null_type, std::less_equal<T>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
template <class Key, class Value = null_type>
|
||||
using rbtree = tree<Key, Value, std::less<Key>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
#endif
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define ll long long
|
||||
#define vec vector
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (r).rbegin(), (x).rend()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
#define FOR(a, b, c) for (int a = b; a < c; ++a)
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
template <typename... Args> void print(string const &str, Args &&...args) {
|
||||
cout << vformat(str, make_format_args(forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <typename T> void print(T const &t) { cout << t; }
|
||||
|
||||
template <ranges::range T> void print(T const &t) {
|
||||
if constexpr (is_same_v<T, string> || is_convertible_v<T, char const *>) {
|
||||
cout << t << '\n';
|
||||
} else {
|
||||
for (const auto &e : t) {
|
||||
cout << e << ' ';
|
||||
}
|
||||
cout << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args> void println(string const &str, Args &&...args) {
|
||||
print(str, fo
|
||||
|
|
@ -1 +0,0 @@
|
|||
#include <bits/stdc++.h>
|
||||
|
|
@ -1,193 +0,0 @@
|
|||
#include <bits/stdc++.h>
|
||||
#include <ext/pb_ds/assoc_container.hpp>
|
||||
#include <ext/pb_ds/tree_policy.hpp>
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
using namespace __gnu_pbds;
|
||||
|
||||
// https://mirror.codeforces.com/blog/entry/124683
|
||||
|
||||
namespace hashing {
|
||||
using i64 = std::int64_t;
|
||||
using u64 = std::uint64_t;
|
||||
static const u64 FIXED_RANDOM =
|
||||
std::chrono::steady_clock::now().time_since_epoch().count();
|
||||
|
||||
#if USE_AES
|
||||
std::mt19937 rd(FIXED_RANDOM);
|
||||
const __m128i KEY1{(i64)rd(), (i64)rd()};
|
||||
const __m128i KEY2{(i64)rd(), (i64)rd()};
|
||||
#endif
|
||||
|
||||
template <class T, class D = void> struct custom_hash {};
|
||||
|
||||
template <class T> inline void hash_combine(u64 &seed, T const &v) {
|
||||
custom_hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T,
|
||||
typename std::enable_if<std::is_integral<T>::value>::type> {
|
||||
u64 operator()(T _x) const {
|
||||
u64 x = _x;
|
||||
#if USE_AES
|
||||
__m128i m{i64(u64(x) * 0xbf58476d1ce4e5b9u64), (i64)FIXED_RANDOM};
|
||||
__m128i y = _mm_aesenc_si128(m, KEY1);
|
||||
__m128i z = _mm_aesenc_si128(y, KEY2);
|
||||
return z[0];
|
||||
#else
|
||||
x += 0x9e3779b97f4a7c15 + FIXED_RANDOM;
|
||||
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
|
||||
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
|
||||
return x ^ (x >> 31);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T, std::void_t<decltype(std::begin(std::declval<T>()))>> {
|
||||
u64 operator()(T const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
for (auto &x : a)
|
||||
hash_combine(value, x);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class... T> struct custom_hash<std::tuple<T...>> {
|
||||
u64 operator()(const std::tuple<T...> &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
std::apply([&value](T const &...args) { (hash_combine(value, args), ...); },
|
||||
a);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class U> struct custom_hash<std::pair<T, U>> {
|
||||
u64 operator()(std::pair<T, U> const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
hash_combine(value, a.first);
|
||||
hash_combine(value, a.second);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}; // namespace hashing
|
||||
|
||||
#ifdef PB_DS_ASSOC_CNTNR_HPP
|
||||
template <class Key, class Value>
|
||||
using hashmap = gp_hash_table<
|
||||
Key, Value, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
template <class Key>
|
||||
using hashset = gp_hash_table<
|
||||
Key, null_type, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_POLICY_HPP
|
||||
template <typename T>
|
||||
using multiset = tree<T, null_type, std::less_equal<T>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
template <class Key, class Value = null_type>
|
||||
using rbtree = tree<Key, Value, std::less<Key>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
#endif
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define ll long long
|
||||
#define vec vector
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (r).rbegin(), (x).rend()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
#define FOR(a, b, c) for (int a = b; a < c; ++a)
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
template <typename... Args> void print(string const &str, Args &&...args) {
|
||||
cout << vformat(str, make_format_args(forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <typename T> void print(T const &t) { cout << t; }
|
||||
|
||||
template <ranges::range T> void print(T const &t) {
|
||||
if constexpr (is_same_v<T, string> || is_convertible_v<T, char const *>) {
|
||||
cout << t << '\n';
|
||||
} else {
|
||||
for (const auto &e : t) {
|
||||
cout << e << ' ';
|
||||
}
|
||||
cout << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args> void println(string const &str, Args &&...args) {
|
||||
print(str, forward<Args>(args)...);
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T> void println(T const &t) { print("{}\n", t); }
|
||||
|
||||
template <ranges::range T> void println(T const &t) {
|
||||
print(t);
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
void println() { cout << '\n'; }
|
||||
|
||||
template <typename T> T max() { return numeric_limits<T>::max(); }
|
||||
|
||||
template <typename T> T min() { return numeric_limits<T>::min(); }
|
||||
|
||||
constexpr static int MOD = 1e9 + 7;
|
||||
|
||||
void solve() {
|
||||
int n, k, d;
|
||||
cin >> n >> k >> d;
|
||||
hashmap<pair<int, int>, int> memo;
|
||||
|
||||
auto dp = [&](auto &self, int n, int d) -> int {
|
||||
if (memo.find({n, d}) != memo.end())
|
||||
return memo[{n, d}];
|
||||
|
||||
if (n == 0)
|
||||
return d == 0 ? 1 : 0;
|
||||
|
||||
ll total = 0;
|
||||
|
||||
FOR(i, 1, min(n + 1, k + 1)) {
|
||||
total = (total + self(self, n - i, i < d ? d : 0)) % MOD;
|
||||
}
|
||||
|
||||
return memo[{n, d}] = total;
|
||||
};
|
||||
|
||||
print(dp(dp, n, d));
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
// cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue