来自 lnw143
#include <cstdio>
#include <string>
#include <cctype>
namespace IO {
static const int BUF = 1<<20;
static char pbuf[BUF],*p=pbuf;
inline char gc() {
static char buf[BUF],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,BUF,stdin),p1==p2)?-1:*p1++;
}
inline void pc(char c) { *p++=c; if(p-pbuf==BUF) fwrite(pbuf,1,BUF,stdout),p=pbuf; }
inline void flush() { fwrite(pbuf,1,p-pbuf,stdout); p=pbuf; }
template<typename T> inline void read(T &x) {
x=0;
char c=gc();
T f=1;
for(; !isdigit(c); c=gc()) if(c=='-') f=-1;
for(; isdigit(c); c=gc()) x=(x<<3)+(x<<1)+(c^48);
x*=f;
}
inline void read(char &c) { c=gc(); }
inline void read(char *p) {
char c=gc();
for(; !isgraph(c); c=gc());
for(; isgraph(c); c=gc()) *p++=c;
*p='\0';
}
inline void read(std::string& s) {
s.clear();
char c=gc();
for(; !isgraph(c); c=gc());
for(; isgraph(c); c=gc()) s+=c;
}
template<typename T,typename ...Args> void read(T &x,Args &...args) { read(x); read(args...); }
template<typename T> inline void write(const T &y) {
T x=y;
if(x<0) {
pc('-');
x=-x;
}
static char stk[1<<8],*tp;
tp=stk;
do *tp++=(x%10)^48; while(x/=10);
while(tp!=stk) pc(*--tp);
}
inline void write(const char &c) { pc(c); }
inline void write(const std::string &s) { for(auto i : s) pc(i); }
inline void write(const char *p) { for(; *p; ++p) pc(*p); }
inline void write(char *p) { write(static_cast<const char*>(p)); }
template<typename T,typename ...Args> void write(const T &x,const Args &...args) { write(x); write(args...); }
struct __Flusher { ~__Flusher() { flush(); } } __flusher;
};
using IO::read;
using IO::write;
using IO::flush;
int main() {
int a,b;
read(a,b);
write(a+b,'\n');
// std::string s,t;
char s[100],t[100];
read(s,t);
write(s,' ',t,'\n');
return 0;
}
压行后:
namespace IO{static const int BUF=1<<20;static char pbuf[BUF],*p=pbuf;inline char gc(){static char buf[BUF],*p1=buf,*p2=buf;return p1==p2&&(p2=(p1=buf)+fread(buf,1,BUF,stdin),p1==p2)?-1:*p1++;}inline void pc(char c){*p++=c;if(p-pbuf==BUF)fwrite(pbuf,1,BUF,stdout),p=pbuf;}inline void flush(){fwrite(pbuf,1,p-pbuf,stdout);p=pbuf;}template<typename T>inline void read(T&x){x=0;char c=gc();T f=1;for(;!isdigit(c);c=gc())if(c=='-')f=-1;for(;isdigit(c);c=gc())x=(x<<3)+(x<<1)+(c^48);x*=f;}inline void read(char&c){c=gc();}inline void read(char*p){char c=gc();for(;!isgraph(c);c=gc());for(;isgraph(c);c=gc())*p++=c;*p='\0';}inline void read(std::string&s){s.clear();char c=gc();for(;!isgraph(c);c=gc());for(;isgraph(c);c=gc())s+=c;}template<typename T,typename...Args>void read(T&x,Args&...args){read(x);read(args...);}template<typename T>inline void write(const T&y){T x=y;if(x<0){pc('-');x=-x;}static char stk[1<<8],*tp;tp=stk;do*tp++=(x%10)^48;while(x/=10);while(tp!=stk)pc(*--tp);}inline void write(const char&c){pc(c);}inline void write(const std::string&s){for(auto i:s)pc(i);}inline void write(const char*p){for(;*p;++p)pc(*p);}inline void write(char*p){write(static_cast<const char*>(p));}template<typename T,typename...Args>void write(const T&x,const Args&...args){write(x);write(args...);}struct __Flusher{~__Flusher(){flush();}}__flusher;};using IO::read;using IO::write;using IO::flush;
本文作者:ZnPdCo
本文链接: https://znpdco.github.io/blog/2024/08/14/fast-fast-read-write/
本页面的全部内容在 CC BY-SA 4.0 和 SATA 协议之条款下提供,附加条款亦可能应用
评论