我使用的是 CP Editor
在使用快读的时候,比如使用 read(n); 时,必须要配上 ios :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 才能运行,不然就会显示 TLE
快读模版如下:
template < typename T > void read(T &x) {
x = 0; char s = getchar(); bool f = 0;
while (! isdigit(s)) { f = s == '-'; s = getchar(); }
while ( isdigit(s)) { x = x * 10 + s - 48; s = getchar(); } if (f) x = -x;
}
template < typename T > void write(T x) {
if (x < 0) { putchar('-'), x = -x; }
if (x > 9) write(x / 10);
putchar(x % 10 + '0');
}
为啥呢?