1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
|
#define DISABLE_PRAGMA_ #ifndef DISABLE_PRAGMA_ #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native") #endif
#include <bits/stdc++.h> #ifdef __GNUG__ #include <bits/stdtr1c++.h> #include <ext/algorithm> #include <ext/rb_tree> #include <ext/rope> #include <ext/vstring.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/priority_queue.hpp> #include <ext/pb_ds/exception.hpp> #include <ext/pb_ds/hash_policy.hpp> #include <ext/pb_ds/list_update_policy.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/trie_policy.hpp> #endif #ifdef LOCAL_ #include <dbg.h> #endif
template <typename T> using remove_cvref_t = typename std::remove_cv_t<typename std::remove_reference_t<T>>;
template <class T> using is_iterable = typename std::conditional_t<std::is_same_v<decltype(std::declval<remove_cvref_t<T>>().begin()), typename remove_cvref_t<T>::iterator> && std::is_same_v<decltype(std::declval<remove_cvref_t<T>>().end()), typename remove_cvref_t<T>::iterator>, std::true_type, std::false_type>;
template <class T> using is_container = typename std::conditional_t<is_iterable<T>::value && !std::is_base_of_v<T, std::basic_string<typename T::value_type>>, std::true_type, std::false_type>;
template <class T> using vec = std::vector<T>; template <class T> using vvec = vec<vec<T>>; template <class T> using vvvec = vec<vvec<T>>; template <class U, class T> using vvp = vvec<std::pair<U, T>>;
template <class T> using ptt = std::pair<T, T>; template <class T> using pt3 = std::tuple<T, T, T>; template <class T> using pt4 = std::tuple<T, T, T, T>;
template <class T> using pq = std::priority_queue<T>; template <class T> using pqg = std::priority_queue<T, vec<T>, std::greater<T>>;
using i8 = int8_t; using i16 = int16_t; using i32 = int32_t; using i64 = int64_t; using i128 = __int128_t; using isz = ptrdiff_t;
using u8 = uint8_t; using u16 = uint16_t; using u32 = uint32_t; using u64 = uint64_t; using u128 = __uint128_t; using usz = size_t;
using f32 = float; using f64 = double; using f128 = long double;
using compi = std::complex<int>; using compi64 = std::complex<i64>; using compd = std::complex<double>; using pii = ptt<int>; using pii64 = ptt<i64>;
constexpr i8 operator""_i8(unsigned long long x) { return (i8)x; } constexpr i16 operator""_i16(unsigned long long x) { return (i16)x; } constexpr i32 operator""_i32(unsigned long long x) { return (i32)x; } constexpr i64 operator""_i64(unsigned long long x) { return (i64)x; } constexpr isz operator""_iz(unsigned long long x) { return (isz)x; }
constexpr u8 operator""_u8(unsigned long long x) { return (u8)x; } constexpr u16 operator""_u16(unsigned long long x) { return (u16)x; } constexpr u32 operator""_u32(unsigned long long x) { return (u32)x; } constexpr u64 operator""_u64(unsigned long long x) { return (u64)x; } constexpr usz operator""_uz(unsigned long long x) { return (usz)x; }
#define for_(i, l, r, vars...) for (std::make_signed_t<decltype(l + r)> i = (l), i##end = (r), ##vars; i <= i##end; ++i) #define for_step_(i, l, r, s, vars...) for (std::make_signed_t<decltype(l + r)> i = (l), i##end = (r), ##vars; i <= i##end; i += s) #define rfor_(i, r, l, vars...) for (std::make_signed_t<decltype(r - l)> i = (r), i##end = (l), ##vars; i >= i##end; --i) #define rfor_step_(i, r, l, s, vars...) for (std::make_signed_t<decltype(r - l)> i = (r), i##end = (l), ##vars; i >= i##end; i -= s) #define foreach_val_(i, container) for (auto i : container) #define foreach_ref_(i, container) for (auto &i : container) #define foreach_cref_(i, container) for (const auto &i : container) #define foreach_rref_(i, container) for (auto &&i : container) #define foreach_binding_(container, vars...) for (auto &&[vars] : container) #define foreach_iter_(it, container) for (auto it = (container).begin(); it != (container).end(); ++it) #define foreach_iter_range_(it, container, l, r) for (auto it = (container).begin() + l; it != (container).begin() + r; ++it) #define foreach_riter_(it, container) for (auto it = (container).rbegin(); it != (container).rend(); ++it) #define foreach_riter_range_(it, container, l, r) for (auto it = (container).rbegin() + l; it != (container).rbegin() + r; ++it) #define ins_(a) std::inserter((a), (a).begin()) #define all_(a) (a).begin(), (a).end() #define rall_(a) (a).rbegin(), (a).rend() #define range_(a, l, r) ((a).begin() + (l)), ((a).begin() + (r)) #define rrange_(a, l, r) ((a).rbegin() + (l)), ((a).rbegin() + (r)) #define set_nul_(a) memset(a, 0, sizeof(a)) #define set_inf_(a) memset(a, 0x3f, sizeof(a)) #define set_nul_n_(a, n) memset(a, 0, sizeof(*(a)) * (n)) #define set_inf_n_(a, n) memset(a, 0x3f, sizeof(*(a)) * (n)) #define run_exec_(expressions, post_process) \ { \ expressions; \ post_process; \ } #define run_exit_(expressions) run_exec_(expressions, exit(0)) #define run_return_(expressions, val) run_exec_(expressions, return val) #define run_return_void_(expressions) run_exec_(expressions, return ) #define run_break_(expressions) run_exec_(expressions, break) #define run_continue_(expressions) run_exec_(expressions, continue) #define read_var_(type, name) \ type name; \ std::cin >> name #define read_container_(type, name, size) \ type name(size); \ foreach_ref_(i, name) std::cin >> i #define intlt2str_(s) STR_____(s) #define STR_____(s) #s #define REif_(expression) \ if (expression) throw std::runtime_error("Line " intlt2str_(__LINE__) ": やだもやだ、無理も無理〜")
template <class T> constexpr auto chkmin(T &a, T b) -> bool { return b < a ? a = b, true : false; } template <class T> constexpr auto chkmax(T &a, T b) -> bool { return a < b ? a = b, true : false; } template <class T> constexpr auto ispow2(T i) -> bool { return i && (i & -i) == i; }
template <class T, std::enable_if_t<is_container<T>::value> * = nullptr> std::ostream &operator<<(std::ostream &os, const T &x) { #ifdef LOCAL_ if (&os == &std::cerr && x.begin() == x.end()) return os << "[]"; #endif if (x.begin() == x.end()) return os; #ifdef LOCAL_ if (&os == &std::cerr) os << '['; if (&os == &std::cerr) for (auto it = x.begin(); it != x.end() - 1; ++it) os << *it << ", "; else #endif for (auto it = x.begin(); it != x.end() - 1; ++it) os << *it << ' '; os << x.back(); #ifdef LOCAL_ if (&os == &std::cerr) os << ']'; #endif return os; }
template <class... Ts> void debug(Ts const &...args) { #ifdef LOCAL_ ((std::cerr << args << '\n'), ...); #endif } #define debug_line_ (std::cerr << __LINE__ << ' ' << __FUNCTION__ << std::endl) #define debug_withname_(var) debug(#var, var) #ifndef LOCAL_ #define dbg(...) (__VA_ARGS__) #endif
constexpr i64 MOD = 1e9 + 7; constexpr double EPS = 1e-6; constexpr i32 INF = 0x3f3f3f3f; constexpr i64 INF64 = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1.); constexpr char DIR_DRUL[4] = {'D', 'R', 'U', 'L'}; constexpr char DIR_SENW[4] = {'S', 'E', 'N', 'W'}; constexpr pii DIR4[4] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; constexpr pii DIR8[8] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}}; constexpr pii DIRH[8] = {{2, 1}, {1, 2}, {-1, 2}, {-2, 1}, {-2, -1}, {-1, -2}, {1, -2}, {2, -1}}; const std::string RES_YN[2] = {"NO", "YES"}; const std::string RES_Yn[2] = {"No", "Yes"}; const std::string RES_yn[2] = {"no", "yes"}; const std::string RES_POSS[2] = {"IMPOSSIBLE", "POSSIBLE"}; const std::string RES_Poss[2] = {"Impossible", "Possible"}; const std::string RES_poss[2] = {"impossible", "possible"}; const std::string RES_Ab[2] = {"Bob", "Alice"};
template <size_t N_> constexpr int64_t EXP10_impl_() { return EXP10_impl_<N_ - 1>() * 10; } template <> constexpr int64_t EXP10_impl_<0>() { return 1; } template <size_t N_> constexpr int64_t EXP10 = EXP10_impl_<N_>();
template <size_t N_> constexpr int64_t FACT10_impl_() { return FACT10_impl_<N_ - 1>() * N_; } template <> constexpr int64_t FACT10_impl_<0>() { return 1; } template <size_t N_> constexpr int64_t FACT = FACT10_impl_<N_>();
using namespace std;
const auto STATIC__ = []() { return 0; }();
auto solve([[maybe_unused]] int t_ = 0) -> void { }
int main() { #ifdef LOCAL_ auto CLOCK_ST_ = std::chrono::high_resolution_clock::now(); std::cerr << std::boolalpha << std::fixed << std::setprecision(6); #endif std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int i_ = STATIC__;
#ifdef MULTI_CASES int t_ = 0; std::cin >> t_; for (i_ = 0; i_ < t_; ++i_) #endif debug("Case", i_), solve(i_); #ifdef LOCAL_ auto CLOCK_ED_ = std::chrono::high_resolution_clock::now(); std::clog << "\n---\nTime used: " << std::chrono::duration_cast<std::chrono::nanoseconds>(CLOCK_ED_ - CLOCK_ST_).count() * 1e-6l << " ms" << std::endl; #endif return 0; }
|