#include <bits/stdc++.h>
#define _FOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define _FRO(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define _ROF(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define mp std::make_pair
#define eb emplace_back
#define pb pop_back
#define fi first
#define se second
#define all(s) s.begin(), s.end()
#define _FFF(i, u, e) for (int(i) = head[(u)]; (i); (i) = (e)[(i)].nxt)
#define file(name) \
freopen(name ".in", "r", stdin); \
freopen(name ".out", "w", stdout);
#define fs(x) std::fixed << std::setprecision(x)
#define il inline
#define Avada_Kedavra return 0
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef __int128 i128;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<pii> vpii;
typedef std::vector<pll> vpll;
typedef std::stack<int> si;
typedef std::stack<ll> sll;
typedef std::stack<pii> spii;
typedef std::stack<pll> spll;
typedef std::queue<int> qi;
typedef std::queue<ll> qll;
typedef std::queue<pii> qpii;
typedef std::queue<pll> qpll;
typedef std::deque<int> dqi;
typedef std::deque<ll> dqll;
typedef std::deque<pii> dqpii;
typedef std::deque<pll> dqpll;
typedef std::priority_queue<int> pqi;
typedef std::priority_queue<ll> pqll;
typedef std::priority_queue<pii> pqpii;
typedef std::priority_queue<pll> pqpll;
typedef std::set<int> siset;
typedef std::set<ll> sllset;
typedef std::set<pii> spiiset;
typedef std::set<pll> spllset;
typedef std::multiset<int> simset;
typedef std::multiset<ll> sllmset;
typedef std::multiset<pii> spiimset;
typedef std::multiset<pll> spllmset;
typedef std::map<int, int> simap;
typedef std::map<ll, ll> sllmap;
typedef std::map<pii, pii> spiimap;
typedef std::map<pll, pll> spllmap;
typedef std::unordered_set<int> siuset;
typedef std::unordered_set<ll> slluset;
typedef std::unordered_set<pii> spiiuset;
typedef std::unordered_set<pll> splluset;
typedef std::unordered_map<int, int> siumap;
typedef std::unordered_map<ll, ll> sllumap;
typedef std::unordered_map<pii, pii> spiiumap;
typedef std::unordered_map<pll, pll> spllumap;
#define _IOS std::ios::sync_with_stdio(false); std::cin.tie(nullptr), std::cout.tie(nullptr)
namespace FastIO {
class FastIOBase {
protected:
#ifdef ONLINE_JUDGE
static const int BUFSIZE = 1 << 16;
char buf[BUFSIZE + 1];
int buf_p = 0;
#endif
FILE *target;
FastIOBase(FILE *f) : target(f) {}
~FastIOBase() = default;
public:
#ifdef ONLINE_JUDGE
virtual void flush() = 0;
#endif
};
class FastOutput final : public FastIOBase {
private:
void __putc(char x) {
#ifdef ONLINE_JUDGE
if (buf[buf_p++] = x, buf_p == BUFSIZE) flush();
#else
putc(x, target);
#endif
}
template <typename T> void __write(T x) {
char stk[std::numeric_limits<T>::digits10 + 1], *top = stk;
if (x < 0) return __putc('-'), __write(-x);
do *(top++) = x % 10, x /= 10;
while (x);
for (; top != stk; __putc(*(--top) + '0'));
}
public:
FastOutput(FILE *f = stdout) : FastIOBase(f) {}
#ifdef ONLINE_JUDGE
~FastOutput() { flush(); }
void flush() { fwrite(buf, 1, buf_p, target), buf_p = 0; }
#endif
FastOutput &operator<< (char x) { return __putc(x), *this; }
FastOutput &operator<< (const char *s) {
for (; *s; __putc(*(s++)));
return *this;
}
FastOutput &operator<< (const std::string &s) {
return (*this) << s.c_str();
}
template <typename T>
std::enable_if_t<std::is_integral<T>::value, FastOutput &> operator<< (const T &x) {
return __write(x), *this;
}
template <typename... T> void writesp(const T &...x) {
std::initializer_list<int>{(this->operator<< (x), __putc(' '), 0)...};
}
template <typename... T> void writeln(const T &...x) {
std::initializer_list<int>{(this->operator<< (x), __putc('\n'), 0)...};
}
template <typename Iter> void writesp(Iter begin, Iter end) {
while (begin != end) (*this) << *(begin++) << ' ';
}
template <typename Iter> void writeln(Iter begin, Iter end) {
while (begin != end) (*this) << *(begin++) << '\n';
}
} qout;
class FastInput final : public FastIOBase {
private:
bool __eof;
public:
FastInput(FILE *f = stdin)
: FastIOBase(f),
__eof(false)
#ifdef ONLINE_JUDGE
{
buf_p = BUFSIZE;
}
void flush() { buf[fread(buf, 1, BUFSIZE, target)] = EOF, buf_p = 0; }
bool eof() const { return buf[buf_p] == EOF; }
#else
{
}
bool eof() const { return feof(target); }
#endif
char get() {
if (__eof) return EOF;
#ifdef ONLINE_JUDGE
if (buf_p == BUFSIZE) flush();
char ch = buf[buf_p++];
#else
char ch = getc(target);
#endif
return ~ch ? ch : (__eof = true, EOF);
}
void unget(char c) {
__eof = false;
#ifdef ONLINE_JUDGE
buf[--buf_p] = c;
#else
ungetc(c, target);
#endif
}
explicit operator bool () const { return !__eof; }
FastInput &operator>> (char &x) {
while (isspace(x = get()));
return *this;
}
template <typename T>
std::enable_if_t<std::is_integral<T>::value, FastInput &> operator>> (T &x) {
char ch, sym = 0;
x = 0;
while (isspace(ch = get()));
if (__eof) return *this;
if (ch == '-') sym = 1, ch = get();
for (; isdigit(ch); x = (x << 1) + (x << 3) + (ch ^ 48), ch = get());
return unget(ch), sym ? x = -x : x, *this;
}
FastInput &operator>> (char *s) {
while (isspace(*s = get()));
if (__eof) return *this;
for (; !isspace(*s) && !__eof; *(++s) = get());
return unget(*s), *s = '\0', *this;
}
FastInput &operator>> (std::string &s) {
char str_buf[(1 << 8) + 1] = {0}, *p = str_buf;
char *const buf_end = str_buf + (1 << 8);
while (isspace(*p = get()));
if (__eof) return *this;
for (s.clear(), p++;; p = str_buf) {
for (; p != buf_end && !isspace(*p = get()) && !__eof; p++);
if (p != buf_end) break;
s.append(str_buf);
}
unget(*p), *p = '\0', s.append(str_buf);
return *this;
}
template <typename... T> void read(T &...x) {
std::initializer_list<int>{(this->operator>> (x), 0)...};
}
template <typename Iter> void read(Iter begin, Iter end) {
while (begin != end) (*this) >> *(begin++);
}
} qin;
} // namespace FastIO
#define read FastIO::qin
#define write FastIO::qout
namespace DEBUG {
#ifndef ONLINE_JUDGE
#define debug(a) std::cerr << "In Line" << __LINE__ << " the " << #a << " = " << a << '\n'
#define look_time std::cerr << clock() * 1e3 / CLOCKS_PER_SEC << " ms\n"
#define look_memory std::cerr << fabs(&med - &mst) / 1024.0 / 1024.0 << " mb\n"
#else
#define debug(...) ((void)0)
#define look_time ((void)0)
#define look_memory ((void)0)
#endif
} // namespace DEBUG
using namespace DEBUG;
namespace basic_algorithm {
template <typename T> il void swap(T &a, T &b) {
T t = a;
a = b, b = t;
}
template <typename T> il T lowbit(T x) { return (x & (-x)); }
template <typename T> il T max(T a, T b) { return a < b ? b : a; }
template <typename T> il T min(T a, T b) { return a > b ? b : a; }
template <typename T, typename... Args> il T max(T a, Args... args) {
return max(a, max(args...));
}
template <typename T, typename... Args> il T min(T a, Args... args) {
return min(a, min(args...));
}
template <typename T> il T abs(T a) { return a >= 0 ? a : -a; }
template <typename T> il T gcd(T a, T b) {
while (b) a %= b, swap(a, b);
return a;
}
template <typename T> il T lcm(T a, T b) { return a / gcd(a, b) * b; }
} // namespace basic_algorithm
using namespace basic_algorithm;
template <ll mod> struct Mint {
ll val;
il Mint(ll v = 0ll) : val((v % mod + mod) % mod) {}
il Mint operator-() const { return Mint(-val); }
il Mint operator+=(const Mint &b) {
if ((val += b.val) >= mod) val -= mod;
return *this;
}
il Mint &operator++() {
val++;
if (val == mod) val = 0;
return *this;
}
il Mint &operator--() {
if (val == 0) val = mod;
val--;
return *this;
}
il Mint operator++(int) {
Mint res = *this;
++*this;
return res;
}
il Mint operator--(int) {
Mint res = *this;
--*this;
return res;
}
il Mint operator-=(const Mint &b) {
if ((val -= b.val) < 0) val += mod;
return *this;
}
il Mint operator*=(const Mint &b) {
val = (val * b.val) % mod;
return *this;
}
il Mint operator/=(const Mint &b) {
return *this *= b.inv();
}
il Mint operator+(const Mint &b) const { return Mint(*this) += b; }
il Mint operator-(const Mint &b) const { return Mint(*this) -= b; }
il Mint operator*(const Mint &b) const { return Mint(*this) *= b; }
il Mint operator/(const Mint &b) const { return Mint(*this) /= b; }
il bool operator==(const Mint &b) const { return val == b.val; }
il bool operator!=(const Mint &b) const { return val != b.val; }
il Mint pow(ll n) const {
assert(n >= 0);
Mint res = 1, w = *this;
for (; n; n >>= 1, w *= w)
if (n & 1) res *= w;
return res;
}
il Mint inv() const { return pow(mod - 2); }
template <typename OUT> il friend OUT &operator<<(OUT &os, const Mint &x) {
return os << x.val;
}
template <typename IN> il friend IN &operator>>(IN &is, Mint &x) {
ll v;
is >> v;
x = Mint(v);
return is;
}
};
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const ll inf = 1e18;
typedef Mint<mod> mint;
bool mst;
bool med;
signed main() {
#ifdef FLOZE_TOT
file("");
#endif
Avada_Kedavra;
}剪贴板
剪贴板 0eni3ajg
剪贴板信息
剪贴板信息
- 收录
- 更新