如题,放个我的
// using fread
#define INPUT_OPTIMIZE
// using fwrite
#define OUTPUT_OPTIMIZE
namespace IO {
#ifdef INPUT_OPTIMIZE
#ifdef __unix__
#include<sys/mman.h>
inline static const char *_read_ptr = (const char *)mmap(nullptr, 0x7fffffff, 1, 2, 0, 0);
#define getchar() (*_read_ptr++)
#else
static char buf[1<<21], *p1 = buf, *p2 = buf;
#define getchar() p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++
#endif
#endif
inline bool read(char *t) {
memset(t, 0, sizeof t);
char *pd = t, c = getchar();
while (isspace(c)) c = getchar();
while (!isspace(c)) *pd++ = c, c = getchar();
return c == EOF;
}
template <typename T>
inline bool read(T &t) {
t=0;T sgn=1;
char c = getchar();
while (!isdigit(c)) {if(c == '-')sgn *= -1;c = getchar();}
while (isdigit(c)) t = (t << 3) + (t << 1) + (c ^ 48), c = getchar();
t*=sgn;
return c == EOF;
}
template <typename T, typename... Args>
inline bool read(T &t, Args&... args) {
return read(t) ? 1 : read(args...);
}
#ifdef OUTPUT_OPTIMIZE
static char outbuf[1<<24], *out = outbuf;
#define putchar(x) *out++ = x
#define flush() fwrite(outbuf, 1, out - outbuf, stdout)
#else
#define flush() 0
#endif
template
<typename T>
inline
void write(T x) {
if (!x) return putchar('0'), void();
static char t[9], p = 0;
while (x) t[++p] = (x % 10) ^ 48, x /= 10;
while (p) putchar(t[p--]);
}
}
using namespace IO;