更好的阅读体验
其实是在 @Register_int 的快读模板上修改了一点。
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define INPUT_OPTIMIZE
#define OUTPUT_OPTIMIZE
namespace IO
{
#ifdef INPUT_OPTIMIZE
#define IMAX 1000000
static char ibuf[IMAX], *p1 = ibuf, *p2 = ibuf;
#define getchar() (p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, IMAX, stdin), p1 == p2) ? EOF : *p1 ++ )
#endif
#ifdef OUTPUT_OPTIMIZE
#define OMAX 1000000
static char obuf[OMAX], *p = obuf;
#define flush() fwrite(obuf, 1, p - obuf, stdout), p = obuf;
inline void putchar(char x)
{
if (p - obuf == OMAX) flush();
*p ++ = x;
}
#else
#define flush() 0
#endif
struct Flusher
{
~Flusher()
{
flush();
}
}flusher;
inline bool read(char *t)
{
memset(t, 0, sizeof t);
char *p = t, c = getchar();
while (isspace(c) && c ^ EOF) c = getchar();
while (!isspace(c) && c ^ EOF) *p ++ = c, c = getchar();
return c == EOF;
}
template<class T> inline bool read(T &t)
{
t = 0; char c = getchar(); bool f = true;
while (isspace(c) && c ^ EOF) c = getchar();
if (c == '-') f = false, c = getchar();
while (isdigit(c) && c ^ EOF) t = (t << 3) + (t << 1) + (c ^ 48), c = getchar();
t *= f ? 1 : -1;
return c == EOF;
}
template<class T, class ...Args> inline bool read(T &t, Args &...args)
{
return read(t) ? true : read(args...);
}
inline void write(const char* s)
{
int l = strlen(s);
for (int i = 0; i < l; i ++ ) putchar(s[i]);
}
template<class T> inline void write(T x)
{
if (x < 0) putchar('-'), x = -x;
if (!x) return putchar('0'), void();
static char t[40], p = 0;
while (x) t[ ++ p] = (x % 10) ^ 48, x /= 10;
while (p) putchar(t[p -- ]);
}
template<class T, class ...Args> inline void write(T &t, Args &...args)
{
write(t), write(args...);
}
}
using namespace IO;
这是干哈子的?
用来快速读入的