Deuteron @ 2023-03-22 21:31:03
rt谁能给一个快读模板,越快越好
问问省选的时候会给快读模板吗
by comcopy @ 2023-03-22 21:33:14
namespace Faster {
inline bool _u(char ch) { return ch >= '0' && ch <= '9'; }
//char buf[1 << 23], *p1 = buf, *p2 = buf;
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 23, stdin), p1 == p2) ? EOF : *p1++)
inline int read() {int x = 0, f = 1;char ch = getchar();for (; !_u(ch); ch = getchar())if (ch == '-')f = -f;for (; _u(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);return x * f;}
inline void write(int num) {static int sta[39], top = 0;if (num < 0)putchar('-'), num *= -1;do sta[++top] = num % 10, num /= 10;while (num);while (top) putchar(sta[top--] | 48);return;}
}using namespace Faster;
@小可爱萌萌哒
删注释是fread
by E1_de5truct0r @ 2023-03-22 21:34:11
#include <bits/stdc++.h>
#define _cst const
#define _IfD long long
#define _siz 20
char buf[1<<_siz],buffer[1<<_siz],*p1=buf,*p2=buf,c=' ';
int op1=-1; _cst int op2=(1<<_siz)-1;
inline char gc(){return (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<_siz,stdin)),p1==p2?EOF:*p1++);}
inline void flush(){fwrite(buffer,1,op1+1,stdout),op1=-1;}
inline void pc(_cst char &x){if(op1==op2)flush();buffer[++op1]=x;}
template<typename T>void read(T &w){
w=0;bool f=1;char ch=gc();
for(;ch<'0' || ch>'9';ch=gc()) if(ch=='-')f=0;
for(;'0'<=ch && ch<='9';ch=gc()) w=(w<<1)+(w<<3)+(ch^48);
w=f?w:-w;
}template<typename T,typename ...Arg>void read(T &w,Arg &...arg){
read(w); read(arg...);
}template<typename T>void wrt(T x){
if(x<0) pc('-'),x=-x;
if(x>9) wrt(x/10);
pc(x%10|48);
}template<typename T>void write(T x){
wrt(x); pc(c);
}template<typename T,typename ...Arg>void write(T x,Arg ...arg){
write(x); write(arg...);
}
template<typename T>inline T qmax(_cst T &a,_cst T &b){return a>b?a:b;}
template<typename T,typename ...Arg>inline T qmax(_cst T &a,_cst T &b,_cst Arg &...arg){return qmax(a,qmax(b,arg...));}
template<typename T>inline T qmin(_cst T &a,_cst T &b){return a<b?a:b;}
template<typename T,typename ...Arg>inline T qmin(_cst T &a,_cst T &b,_cst Arg &...arg){return qmin(a,qmin(b,arg...));}
template<typename T>inline void qswap(T &a,T &b){a+=b,b=a-b,a-=b;}```
by dk_qwq @ 2023-03-22 21:40:41
namespace INPUT{
char buf[1<<20],*p1,*p2;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
}
using namespace INPUT;
template<typename T>
inline T read(){
T x=0,p=1;
char ch=gc();
for(;ch<'0'||ch>'9';ch=gc())
if(ch=='-') p=-1;
for(;ch>='0'&&ch<='9';ch=gc())
x=(x<<3)+(x<<1)+(ch^48);
return x*p;
}
不会给吧
by dk_qwq @ 2023-03-22 21:41:24
@dk_qwq 这个考场写也是ok的,其他的太难记了:(
by XeCtera @ 2023-03-22 21:43:12
#define gc (l==r&&(r=(l=c)+fread(c,1,65536,stdin),l==r)?EOF:*l++)
char c[65536],*l=c,*r=c;
inline int read() {
int x=0,f=0; char ch=gc;
while (!isdigit(ch)) f|=(ch=='-'),ch=gc;
while (isdigit(ch)) x=x*10+(ch^48),ch=gc;
return f?-x:x;
}
一个比较适合考场的写法。
by Killer_joke @ 2023-03-22 22:01:14
#include<bits/stdc++.h>
#include<sys/mman.h>
char* s;
void rd(int &x){
for(;*s<=' ';){++s;}
for(x=0;*s>'0';++s){x=x*10+(*s&15);}
}
int main(){
//freopen(....)
s = (char*)mmap(0,1<<26,1,2,fileno(stdin),0);
return 0;
}
by 5k_sync_closer @ 2023-03-23 08:11:03
@Killer_joke 考场不让 mmap 吧