跳到正文

剪贴板

剪贴板 i5v9bfot

原文
剪贴板信息

剪贴板信息

收录
更新

快读快写 / mmap

返回上页\rule{120pt}{30pt}\kern{-85pt}\color{white}\raisebox{12pt}{\sf 返回上页}

C++
#include <sys/mman.h>

namespace FastIO {
	const int SZ = 1 << 18;

#define _Input (char*) mmap(0, 1LL << 29, PROT_READ, MAP_SHARED, 0, 0)
	char obuf[SZ];
	char *input = _Input, *p = obuf;
#define getchar() (*input++)
#define putchar(x) ((p == obuf + SZ) && (fwrite(obuf, p - obuf, 1, stdout), p = obuf), *p++ = x)

	inline void skip() {for (char ch = getchar(); ch == ' ' || ch == '\n' || ch == '\t'; ch = getchar());}
	int t; char ch;
	template <typename T> inline void read(T& x) {x = 0, t = 1, ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') t = -1; for (; '0' <= ch && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); x *= t;}
	inline void read(char& x) {skip(), x = getchar();}
	template <typename T, typename... Args> inline void read(T& t, Args&... args) {read(t); read(args...);}
	template <typename It> inline void read(const It& begin, const It& end) {for (It it = begin; it != end; it++) read(*it);}

	inline void flush() {fwrite(obuf, p - obuf, 1, stdout);}

	template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; static int st[40]; int top = 0; do {st[top++] = x % 10, x /= 10;} while (x); while (top) putchar(st[--top] ^ 48);}
	inline void write(const char c) {putchar(c);}
	inline void write(const std::string& s) {for (char c : s) putchar(c);}
	template <typename T> inline void write(const char c, const T x) {write(x), putchar(c);}
	template <typename T, typename... Args> inline void write(T t, const char c, Args... args) {write(c, t); write(c, args...);}
	template <typename T> inline void writeln(const T x) {write(x), putchar('\n');}
	template <typename T> inline void writesp(const T x) {write(x), putchar(' ');}
	template <typename It> inline void write(const char c, const It& begin, const It& end) {for (It it = begin; it != end; it++) write(*it), putchar(c);}
} using namespace FastIO;