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
| using namespace std; typedef long long ll;
#define repi(i,b,e) for (int i = (b), _ = (e); i < _; ++i) #define rep(i,b,e) for (int i = (b), _ = (e); i <= _; ++i) #define repr(i,b,e) for (int i = (b), _ = (e); i >= _; --i) #define repit(t,i,c) for (t i = (c).begin(); i != (c).end(); ++i)
template <typename T> T& up_mx(T& v, T nv) { if (v < nv) v = nv; return v; }
template <typename T> T& up_mn(T& v, T nv) { if (v > nv) v = nv; return v; }
static int sc_ret = 0; struct _sp { _sp& operator >> (char& v) { sc_ret = scanf(" %c", &v); return *this; } _sp& operator >> (int& v) { sc_ret = scanf("%d", &v); return *this; } _sp& operator >> (unsigned& v) { sc_ret = scanf("%u", &v); return *this; } _sp& operator >> (double& v) { sc_ret = scanf("%lf", &v); return *this; } _sp& operator >> (char* v) { sc_ret = scanf("%s", v); return *this; } _sp& operator >> (string& v) { sc_ret = (bool)(cin >> v); return *this; } _sp& operator >> (ll& v) { sc_ret = read(v); return *this; } _sp& ch(char& v) { v = sc_ret = getchar(); return *this; } _sp& gets(char* v) { sc_ret = fgets(v, INT_MAX, stdin) != 0; v[strlen(v) - 1] = 0; return *this; } operator bool() const { return sc_ret > 0; } template <typename T> int read(T& v) { T k = 1; v = 0; int c = getchar(); while (c < '0' || c > '9') { if (c == '-') k = 0; c = getchar(); } while (c >= '0' && c <= '9') v = (v << 3) + (v << 1) + (c - 48), c = getchar(); if (k == 0) v = -v; return c; } _sp& operator<<(char v) { putchar(v); return *this; } _sp& operator<<(int v) { printf("%d", v); return *this; } _sp& operator<<(unsigned v) { printf("%u", v); return *this; } _sp& operator<<(double v) { printf("%.2f", v); return *this; } _sp& operator()(const char* fmt, double v) { printf(fmt, v); return *this; } _sp& operator<<(const char* v) { printf("%s", v); return *this; } _sp& operator<<(string v) { printf("%s", v.c_str()); return *this; } _sp& operator<<(ll v) { write(v); return *this; } void flush() { fflush(stdout); } template <typename T> void write(T v) { int cnt = 0; char c[23]; if (v == 0) { putchar('0'); return; } if (v < 0) putchar('-'), v = -v; while (v) c[++cnt] = (v % 10) + 48, v /= 10; while (cnt > 0) putchar(c[cnt--]); } }io; struct fastio { fastio() { cin.tie(0); ios::sync_with_stdio(0); } }fio; namespace cio { _sp& qin = io; _sp& qout = io; char nl = '\n'; } namespace cppio { istream& qin = std::cin; ostream& qout = std::cout; char nl = '\n'; } using namespace cio;
template <typename T> void arrln(T* arr, int size, char split = ' ') { if (size > 0) { qout << arr[0]; for (int i = 1; i < size; ++i) qout << split, qout << arr[i]; } qout << '\n'; }
|