Home
Problem
Status
Contest
Workbook
User
Group
Forum
Register
Login
{"managingGroups":{},"author":"CMinusMinus","updateTime":1679929960000,"title":"IO优化模板","dislikeCnt":0,"content":"```cpp\n#ifndef DEBUG\nnamespace IO {\n constexpr int sz \u003d 1 \u003c\u003c 21;\n char ib[sz], *s \u003d ib, *t \u003d ib;\n#define getchar IO::getc\n inline int getc() {\n return s \u003d\u003d t \u0026\u0026 (t \u003d (s \u003d ib) + fread(ib, 1, sz, stdin), s \u003d\u003d t) ? EOF : *s++;\n }\n \n char ob[sz + 99];\n int p \u003d 0;\n inline void flush() { fwrite(ob, 1, p, stdout), p \u003d 0; }\n struct F { ~F() { flush(); } } f; //Don\u0027t call fclose\n#define putchar IO::putc\n inline void putc(int c) {\n ob[p++] \u003d c;\n if (p \u003e\u003d sz) { flush(); }\n }\n}\n#endif\n\ntemplate \u003cclass T\u003e\ninline void read(T \u0026x) {\n bool f \u003d x \u003d 0;\n char c;\n while (!isdigit(c \u003d getchar())) if (c \u003d\u003d \u0027-\u0027) { f \u003d 1; }\n for (; isdigit(c); x \u003d c - \u00270\u0027 + x * 10, c \u003d getchar());\n if (f) { x \u003d -x; }\n}\ntemplate\u003cclass T, class ...Args\u003e inline void read(T \u0026x, Args\u0026 ...args) {\n read(x), read(args...);\n}\n//can\u0027t output -1\u003c\u003c31 or -1LL\u003c\u003c63\ntemplate \u003cclass T\u003e\nvoid write(T x) {\n if (x \u003c 0) { putchar(\u0027-\u0027), x \u003d -x; }\n if (x \u003e\u003d 10) { write(x / 10); }\n putchar(x % 10 + \u00270\u0027);\n}\ntemplate\u003c\u003e void write(char c) {putchar(c);}\ntemplate\u003cclass T, class ...Args\u003e inline void write(T x, Args ...args) {\n write(x), write(args...);\n}\n```","likeCnt":0,"createTime":1567316390000,"isWorkbook":false,"viewCnt":933,"openness":1,"fav":false,"id":1416,"trustable":false}