diff --git a/.gitignore b/.gitignore index 437d54b..0296075 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.null-ls.* +.null-ls* *.debug *.run *.su diff --git a/codeforces/1037/.null-ls_118668_c.cc b/codeforces/1037/.null-ls_118668_c.cc deleted file mode 100644 index b176282..0000000 --- a/codeforces/1037/.null-ls_118668_c.cc +++ /dev/null @@ -1,76 +0,0 @@ -#include // {{{ - -// 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 -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); - -template -[[nodiscard]] static T sc(auto&& x) { - return static_cast(x); -} - -template -[[nodiscard]] static T sz(auto&& x) { - return static_cast(x.size()); -} -#endif - -static void NO() { - std::cout << "NO\n"; -} - -static void YES() { - std::cout << "YES\n"; -} - -template -using vec = std::vector; - -#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; -} diff --git a/codeforces/1037/.null-ls_161868_c.cc b/codeforces/1037/.null-ls_161868_c.cc deleted file mode 100644 index 8381a1d..0000000 --- a/codeforces/1037/.null-ls_161868_c.cc +++ /dev/null @@ -1,62 +0,0 @@ -#include // {{{ - -// 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 -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); - -template -[[nodiscard]] static T sc(auto&& x) { - return static_cast(x); -} - -template -[[nodiscard]] static T sz(auto&& x) { - return static_cast(x.size()); -} -#endif - -static void NO() { - std::cout << "NO\n"; -} - -static void YES() { - std::cout << "YES\n"; -} - -template -using vec = std::vector; - -#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() { - -} diff --git a/codeforces/1037/.null-ls_183251_c.cc b/codeforces/1037/.null-ls_183251_c.cc deleted file mode 100644 index 45de929..0000000 --- a/codeforces/1037/.null-ls_183251_c.cc +++ /dev/null @@ -1,73 +0,0 @@ -#include // {{{ - -// 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 -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); - -template -[[nodiscard]] static T sc(auto&& x) { - return static_cast(x); -} - -template -[[nodiscard]] static T sz(auto&& x) { - return static_cast(x.size()); -} -#endif - -static void NO() { - std::cout << "NO\n"; -} - -static void YES() { - std::cout << "YES\n"; -} - -template -using vec = std::vector; - -#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(); - } diff --git a/codeforces/1037/.null-ls_466333_c.cc b/codeforces/1037/.null-ls_466333_c.cc deleted file mode 100644 index a58dabe..0000000 --- a/codeforces/1037/.null-ls_466333_c.cc +++ /dev/null @@ -1,61 +0,0 @@ -#include // {{{ - -// 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 -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); - -template -[[nodiscard]] static T sc(auto&& x) { - return static_cast(x); -} - -template -[[nodiscard]] static T sz(auto&& x) { - return static_cast(x.size()); -} -#endif - -static void NO() { - std::cout << "NO\n"; -} - -static void YES() { - std::cout << "YES\n"; -} - -template -using vec = std::vector; - -#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() { - diff --git a/codeforces/1037/.null-ls_497923_c.cc b/codeforces/1037/.null-ls_497923_c.cc deleted file mode 100644 index ab58ade..0000000 --- a/codeforces/1037/.null-ls_497923_c.cc +++ /dev/null @@ -1,71 +0,0 @@ -#include // {{{ - -// 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 -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); - -template -[[nodiscard]] static T sc(auto&& x) { - return static_cast(x); -} - -template -[[nodiscard]] static T sz(auto&& x) { - return static_cast(x.size()); -} -#endif - -static void NO() { - std::cout << "NO\n"; -} - -static void YES() { - std::cout << "YES\n"; -} - -template -using vec = std::vector; - -#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) { diff --git a/codeforces/1037/.null-ls_726190_c.cc b/codeforces/1037/.null-ls_726190_c.cc deleted file mode 100644 index c57c398..0000000 --- a/codeforces/1037/.null-ls_726190_c.cc +++ /dev/null @@ -1,64 +0,0 @@ -#include // {{{ - -// 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 -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); - -template -[[nodiscard]] static T sc(auto&& x) { - return static_cast(x); -} - -template -[[nodiscard]] static T sz(auto&& x) { - return static_cast(x.size()); -} -#endif - -static void NO() { - std::cout << "NO\n"; -} - -static void YES() { - std::cout << "YES\n"; -} - -template -using vec = std::vector; - -#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() { diff --git a/codeforces/1037/.null-ls_739113_c.cc b/codeforces/1037/.null-ls_739113_c.cc deleted file mode 100644 index d539506..0000000 --- a/codeforces/1037/.null-ls_739113_c.cc +++ /dev/null @@ -1,60 +0,0 @@ -#include // {{{ - -// 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 -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); - -template -[[nodiscard]] static T sc(auto&& x) { - return static_cast(x); -} - -template -[[nodiscard]] static T sz(auto&& x) { - return static_cast(x.size()); -} -#endif - -static void NO() { - std::cout << "NO\n"; -} - -static void YES() { - std::cout << "YES\n"; -} - -template -using vec = std::vector; - -#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() { diff --git a/codeforces/1037/.null-ls_783881_c.cc b/codeforces/1037/.null-ls_783881_c.cc deleted file mode 100644 index 8b13789..0000000 --- a/codeforces/1037/.null-ls_783881_c.cc +++ /dev/null @@ -1 +0,0 @@ - diff --git a/codeforces/1037/.null-ls_878331_c.cc b/codeforces/1037/.null-ls_878331_c.cc deleted file mode 100644 index d989d60..0000000 --- a/codeforces/1037/.null-ls_878331_c.cc +++ /dev/null @@ -1,77 +0,0 @@ -#include // {{{ - -// 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 -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); - -template -[[nodiscard]] static T sc(auto&& x) { - return static_cast(x); -} - -template -[[nodiscard]] static T sz(auto&& x) { - return static_cast(x.size()); -} -#endif - -static void NO() { - std::cout << "NO\n"; -} - -static void YES() { - std::cout << "YES\n"; -} - -template -using vec = std::vector; - -#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; -} -// } diff --git a/codeforces/1037/.null-ls_952410_c.cc b/codeforces/1037/.null-ls_952410_c.cc deleted file mode 100644 index 2257c09..0000000 --- a/codeforces/1037/.null-ls_952410_c.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include // {{{ - -// 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 -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); - -template -[[nodiscard]] static T sc(auto&& x) { - return static_cast(x); -} - -template -[[nodiscard]] static T sz(auto&& x) { - return static_cast(x.size()); -} -#endif - -static void NO() { - std::cout << "NO\n"; -} - -static void YES() { - std::cout << "YES\n"; -} - -template -using vec = std::vector; - -#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 -// }}} diff --git a/codeforces/431/.null-ls_210584_c.cc b/codeforces/431/.null-ls_210584_c.cc deleted file mode 100644 index 2462f22..0000000 --- a/codeforces/431/.null-ls_210584_c.cc +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/codeforces/431/.null-ls_213694_c.cc b/codeforces/431/.null-ls_213694_c.cc deleted file mode 100644 index 35605d1..0000000 --- a/codeforces/431/.null-ls_213694_c.cc +++ /dev/null @@ -1,139 +0,0 @@ -#include -#include -#include - -#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 struct custom_hash {}; - -template inline void hash_combine(u64 &seed, T const &v) { - custom_hash hasher; - seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4); -}; - -template -struct custom_hash::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 -struct custom_hash()))>> { - u64 operator()(T const &a) const { - u64 value = FIXED_RANDOM; - for (auto &x : a) - hash_combine(value, x); - return value; - } -}; - -template struct custom_hash> { - u64 operator()(const std::tuple &a) const { - u64 value = FIXED_RANDOM; - std::apply([&value](T const &...args) { (hash_combine(value, args), ...); }, - a); - return value; - } -}; - -template struct custom_hash> { - u64 operator()(std::pair 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 -using hashmap = gp_hash_table< - Key, Value, hashing::custom_hash, std::equal_to, - direct_mask_range_hashing<>, linear_probe_fn<>, - hash_standard_resize_policy, - hash_load_check_resize_trigger<>, true>>; -template -using hashset = gp_hash_table< - Key, null_type, hashing::custom_hash, std::equal_to, - direct_mask_range_hashing<>, linear_probe_fn<>, - hash_standard_resize_policy, - hash_load_check_resize_trigger<>, true>>; - -#endif -#ifdef PB_DS_TREE_POLICY_HPP -template -using multiset = tree, rb_tree_tag, - tree_order_statistics_node_update>; -template -using rbtree = tree, 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((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 void print(string const &str, Args &&...args) { - cout << vformat(str, make_format_args(forward(args)...)); -} - -template void print(T const &t) { cout << t; } - -template void print(T const &t) { - if constexpr (is_same_v || is_convertible_v) { - cout << t << '\n'; - } else { - for (const auto &e : t) { - cout << e << ' '; - } - cout << '\n'; - } -} - -template void println(string const &str, Args &&...args) { - print(str, fo diff --git a/codeforces/431/.null-ls_271044_c.cc b/codeforces/431/.null-ls_271044_c.cc deleted file mode 100644 index aa8bdaa..0000000 --- a/codeforces/431/.null-ls_271044_c.cc +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include -#include - -#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 struct custom_hash {}; - -template inline void hash_combine(u64 &seed, T const &v) { - custom_hash hasher; - seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4); -}; - -template -struct custom_hash::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 -struct custom_hash()))>> { - u64 operator()(T const &a) const { - u64 value = FIXED_RANDOM; - for (auto &x : a) - hash_combine(value, x); - return value; - } -}; - -template struct custom_hash> { - u64 operator()(const std::tuple &a) const { - u64 value = FIXED_RANDOM; - std::apply([&value](T const &...args) { (hash_combine(value, args), ...); }, - a); - return value; - } -}; - -template struct custom_hash> { - u64 operator()(std::pair 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 -using hashmap = gp_hash_table< - Key, Value, hashing::custom_hash, std::equal_to, - direct_mask_range_hashing<>, linear_probe_fn<>, - hash_standard_resize_policy, - hash_load_check_resize_trigger<>, true>>; -template -using hashset = gp_hash_table< - Key, null_type, hashing::custom_hash, std::equal_to, - direct_mask_range_hashing<>, linear_probe_fn<>, - hash_standard_resize_policy, - hash_load_check_resize_trigger<>, true>>; - -#endif -#ifdef PB_DS_TREE_POLICY_HPP -template -using multiset = tree, rb_tree_tag, - tree_order_statistics_node_update>; -template -using rbtree = tree, 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((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 void print(string const &str, Args &&...args) { - cout << vformat(str, make_format_args(forward(args)...)); -} - -template void print(T const &t) { cout << t; } - -template void print(T const &t) { - if constexpr (is_same_v || is_convertible_v) { - cout << t << '\n'; - } else { - for (const auto &e : t) { - cout << e << ' '; - } - cout << '\n'; - } -} - -template void println(string const &str, Args &&...args) { - print(str, forward(args)...); - cout << '\n'; -} - -template void println(T const &t) { print("{}\n", t); } - -template void println(T const &t) { - print(t); - cout << '\n'; -} - -void println() { cout << '\n'; } - -template T max() { return numeric_limits::max(); } - -template T min() { return numeric_limits::min(); } - -constexpr static int MOD = 1e9 + 7; - -void solve() { - int n, k, d; - cin >> n >> k >> d; - hashmap, 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; -} diff --git a/codeforces/431/.null-ls_427011_c.cc b/codeforces/431/.null-ls_427011_c.cc deleted file mode 100644 index aa8bdaa..0000000 --- a/codeforces/431/.null-ls_427011_c.cc +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include -#include - -#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 struct custom_hash {}; - -template inline void hash_combine(u64 &seed, T const &v) { - custom_hash hasher; - seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4); -}; - -template -struct custom_hash::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 -struct custom_hash()))>> { - u64 operator()(T const &a) const { - u64 value = FIXED_RANDOM; - for (auto &x : a) - hash_combine(value, x); - return value; - } -}; - -template struct custom_hash> { - u64 operator()(const std::tuple &a) const { - u64 value = FIXED_RANDOM; - std::apply([&value](T const &...args) { (hash_combine(value, args), ...); }, - a); - return value; - } -}; - -template struct custom_hash> { - u64 operator()(std::pair 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 -using hashmap = gp_hash_table< - Key, Value, hashing::custom_hash, std::equal_to, - direct_mask_range_hashing<>, linear_probe_fn<>, - hash_standard_resize_policy, - hash_load_check_resize_trigger<>, true>>; -template -using hashset = gp_hash_table< - Key, null_type, hashing::custom_hash, std::equal_to, - direct_mask_range_hashing<>, linear_probe_fn<>, - hash_standard_resize_policy, - hash_load_check_resize_trigger<>, true>>; - -#endif -#ifdef PB_DS_TREE_POLICY_HPP -template -using multiset = tree, rb_tree_tag, - tree_order_statistics_node_update>; -template -using rbtree = tree, 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((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 void print(string const &str, Args &&...args) { - cout << vformat(str, make_format_args(forward(args)...)); -} - -template void print(T const &t) { cout << t; } - -template void print(T const &t) { - if constexpr (is_same_v || is_convertible_v) { - cout << t << '\n'; - } else { - for (const auto &e : t) { - cout << e << ' '; - } - cout << '\n'; - } -} - -template void println(string const &str, Args &&...args) { - print(str, forward(args)...); - cout << '\n'; -} - -template void println(T const &t) { print("{}\n", t); } - -template void println(T const &t) { - print(t); - cout << '\n'; -} - -void println() { cout << '\n'; } - -template T max() { return numeric_limits::max(); } - -template T min() { return numeric_limits::min(); } - -constexpr static int MOD = 1e9 + 7; - -void solve() { - int n, k, d; - cin >> n >> k >> d; - hashmap, 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; -} diff --git a/codeforces/431/.null-ls_433724_c.cc b/codeforces/431/.null-ls_433724_c.cc deleted file mode 100644 index 35605d1..0000000 --- a/codeforces/431/.null-ls_433724_c.cc +++ /dev/null @@ -1,139 +0,0 @@ -#include -#include -#include - -#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 struct custom_hash {}; - -template inline void hash_combine(u64 &seed, T const &v) { - custom_hash hasher; - seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4); -}; - -template -struct custom_hash::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 -struct custom_hash()))>> { - u64 operator()(T const &a) const { - u64 value = FIXED_RANDOM; - for (auto &x : a) - hash_combine(value, x); - return value; - } -}; - -template struct custom_hash> { - u64 operator()(const std::tuple &a) const { - u64 value = FIXED_RANDOM; - std::apply([&value](T const &...args) { (hash_combine(value, args), ...); }, - a); - return value; - } -}; - -template struct custom_hash> { - u64 operator()(std::pair 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 -using hashmap = gp_hash_table< - Key, Value, hashing::custom_hash, std::equal_to, - direct_mask_range_hashing<>, linear_probe_fn<>, - hash_standard_resize_policy, - hash_load_check_resize_trigger<>, true>>; -template -using hashset = gp_hash_table< - Key, null_type, hashing::custom_hash, std::equal_to, - direct_mask_range_hashing<>, linear_probe_fn<>, - hash_standard_resize_policy, - hash_load_check_resize_trigger<>, true>>; - -#endif -#ifdef PB_DS_TREE_POLICY_HPP -template -using multiset = tree, rb_tree_tag, - tree_order_statistics_node_update>; -template -using rbtree = tree, 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((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 void print(string const &str, Args &&...args) { - cout << vformat(str, make_format_args(forward(args)...)); -} - -template void print(T const &t) { cout << t; } - -template void print(T const &t) { - if constexpr (is_same_v || is_convertible_v) { - cout << t << '\n'; - } else { - for (const auto &e : t) { - cout << e << ' '; - } - cout << '\n'; - } -} - -template void println(string const &str, Args &&...args) { - print(str, fo diff --git a/codeforces/431/.null-ls_441630_c.cc b/codeforces/431/.null-ls_441630_c.cc deleted file mode 100644 index 2462f22..0000000 --- a/codeforces/431/.null-ls_441630_c.cc +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/codeforces/431/.null-ls_544573_c.cc b/codeforces/431/.null-ls_544573_c.cc deleted file mode 100644 index aa8bdaa..0000000 --- a/codeforces/431/.null-ls_544573_c.cc +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include -#include - -#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 struct custom_hash {}; - -template inline void hash_combine(u64 &seed, T const &v) { - custom_hash hasher; - seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4); -}; - -template -struct custom_hash::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 -struct custom_hash()))>> { - u64 operator()(T const &a) const { - u64 value = FIXED_RANDOM; - for (auto &x : a) - hash_combine(value, x); - return value; - } -}; - -template struct custom_hash> { - u64 operator()(const std::tuple &a) const { - u64 value = FIXED_RANDOM; - std::apply([&value](T const &...args) { (hash_combine(value, args), ...); }, - a); - return value; - } -}; - -template struct custom_hash> { - u64 operator()(std::pair 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 -using hashmap = gp_hash_table< - Key, Value, hashing::custom_hash, std::equal_to, - direct_mask_range_hashing<>, linear_probe_fn<>, - hash_standard_resize_policy, - hash_load_check_resize_trigger<>, true>>; -template -using hashset = gp_hash_table< - Key, null_type, hashing::custom_hash, std::equal_to, - direct_mask_range_hashing<>, linear_probe_fn<>, - hash_standard_resize_policy, - hash_load_check_resize_trigger<>, true>>; - -#endif -#ifdef PB_DS_TREE_POLICY_HPP -template -using multiset = tree, rb_tree_tag, - tree_order_statistics_node_update>; -template -using rbtree = tree, 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((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 void print(string const &str, Args &&...args) { - cout << vformat(str, make_format_args(forward(args)...)); -} - -template void print(T const &t) { cout << t; } - -template void print(T const &t) { - if constexpr (is_same_v || is_convertible_v) { - cout << t << '\n'; - } else { - for (const auto &e : t) { - cout << e << ' '; - } - cout << '\n'; - } -} - -template void println(string const &str, Args &&...args) { - print(str, forward(args)...); - cout << '\n'; -} - -template void println(T const &t) { print("{}\n", t); } - -template void println(T const &t) { - print(t); - cout << '\n'; -} - -void println() { cout << '\n'; } - -template T max() { return numeric_limits::max(); } - -template T min() { return numeric_limits::min(); } - -constexpr static int MOD = 1e9 + 7; - -void solve() { - int n, k, d; - cin >> n >> k >> d; - hashmap, 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; -} diff --git a/kattis/18-2-2025/.null-ls_478791_k.py b/kattis/18-2-2025/.null-ls_478791_k.py deleted file mode 100644 index d71a00e..0000000 --- a/kattis/18-2-2025/.null-ls_478791_k.py +++ /dev/null @@ -1,37 +0,0 @@ -import math -from scipy.optimize import minimize_scalar - -def cable_length(x, L, H1, H2, d, h): - # Calculate the height of the cable at point x - y = H1 - (H1 - H2) * (x / L) - - # Ensure the rider is at least h + d meters above the ground - if y - d < h: - return float('inf') # Invalid configuration - - # Calculate the cable length - length1 = math.sqrt(x**2 + (H1 - y)**2) - length2 = math.sqrt((L - x)**2 + (H2 - y)**2) - return length1 + length2 - -def find_min_max_length(L, H1, H2, d, h): - # Find the minimum length - res_min = minimize_scalar(lambda x: cable_length(x, L, H1, H2, d, h), bounds=(0, L), method='bounded') - min_length = res_min.fun - - # Find the maximum length - res_max = minimize_scalar(lambda x: -cable_length(x, L, H1, H2, d, h), bounds=(0, L), method='bounded') - max_length = -res_max.fun - - return min_length, max_length - -# Example usage: -L = 1000 # Distance between poles -H1 = 100 # Height of first pole -H2 = 100 # Height of second pole -d = 20 # Distance rider hangs below cable -h = 10 # Minimum height above ground - -min_length, max_length = find_min_max_length(L, H1, H2, d, h) -print(f"Minimum length: {min_length:.6f} meters") -print(f"Maximum length: {max_length:.6f} meters")