-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFastIO.cpp
More file actions
62 lines (52 loc) · 1.1 KB
/
Copy pathFastIO.cpp
File metadata and controls
62 lines (52 loc) · 1.1 KB
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
// 究极快读
namespace fastread {
const unsigned int S = 1 << 16;
char B[S + 3], *H, *T;
inline unsigned int gc() {
if (H == T) T = (H = B) + fread(B, 1, S, stdin);
return (H == T) ? EOF : *H++;
}
inline unsigned int read() {
unsigned int x, ch;
while ((ch = gc()) < 48)
;
x = ch ^ '0';
while ((ch = gc()) > 47)
x = x * 10 + (ch ^ '0');
return x;
}
} // namespace fastread
using fastread::read;
// 究极快写
namespace fastwrite {
const unsigned int S = 1 << 16;
unsigned int cnt;
char B[S + 3];
inline void write(unsigned int x) {
if (x > 9) write(x / 10);
B[cnt++] = (x % 10) | 48;
if (cnt == S) {
fwrite(B, 1, S, stdout);
cnt = 0;
}
}
inline void space() {
B[cnt++] = 32;
if (cnt == S) {
fwrite(B, 1, S, stdout);
cnt = 0;
}
}
inline void nl() {
B[cnt++] = 10;
if (cnt == S) {
fwrite(B, 1, S, stdout);
cnt = 0;
}
}
inline void show() {
fwrite(B, 1, cnt, stdout);
cnt = 0;
}
} // namespace fastwrite
using fastwrite::write, fastwrite::space, fastwrite::show, fastwrite::nl;