跳到正文

科技·工程

超级超级快读!!!!!

f_hxr_约 3 分钟
原文
文章信息与版本

文章信息

发布
2024年4月17日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 3 分钟

版本

  1. v1当前

快到什么程度?

众所周知,pb_ds 里的 splay 比红黑树要慢些。比如P5314。如果不用快读写就只能有 80 分。

但是如果你用上了这个快读快写,即使是用 splay 也能 AC !!!

当然,这玩意只能读整数

顺便提一句,如果你是用控制台输入输出输入完后一定要 Ctrl+Z。当然如果你用的是文件输入输出可以忽略这句话。

C++
#include <bits/stdc++.h>
namespace IO{
	char buff[1<<21],*P1OfFastIO=buff,*P2OfFastIO=buff;
	#define getch() (P1OfFastIO==P2OfFastIO&&(P2OfFastIO=((P1OfFastIO=buff)+fread(buff,1,1<<21,stdin)),P1OfFastIO==P2OfFastIO)?EOF:*P1OfFastIO++)
	template<typename T>
	void read(T &x){char CHOfFastIO=getch();int fl=1;x=0;while(CHOfFastIO>'9'||CHOfFastIO<'0'){if(CHOfFastIO=='-')fl=-1;CHOfFastIO=getch();}while(CHOfFastIO<='9'&&CHOfFastIO>='0'){x=x*10+CHOfFastIO-48;CHOfFastIO=getch();}x*=fl;}
	template<typename T,typename ...Args>
	void read(T &x,Args& ...args){read(x);read(args...);}
	char obuf[1<<21],*P3OfFastIO=obuf;
	inline void putch(char CHOfFastIO){if(P3OfFastIO-obuf<(1<<21))*P3OfFastIO++=CHOfFastIO;else fwrite(obuf,P3OfFastIO-obuf,1,stdout),P3OfFastIO=obuf,*P3OfFastIO++=CHOfFastIO;}
	char CHOfFastIO[100];template<typename T>
	void write(T x){if(!x)return putch('0');if(x<0)putch('-'),x*=-1;int top=0;while(x)CHOfFastIO[++top]=x%10+48,x/=10;while(top)putch(CHOfFastIO[top]),top--;}
	template<typename T,typename ...Args>
	void write(T x,Args ...args){write(x);write(args...);}
	inline void flush(){fwrite(obuf,P3OfFastIO-obuf,1,stdout);}
}using namespace IO;
int main(){
	int FuckCCF;read(FuckCCF);
	write(FuckCCF);
	flush();//最后一定要加这个 
	//顺便提一句,如果你是用控制台输入输出输入完后一定要 `Ctrl+Z`。
	//当然如果你用的是文件输入输出可以忽略这句话。
	return 0;
}
原文