cin, cout效率优化
最近发现简单题目所花费时间都很多,原因是cin, cout效率太低
因为C++为了兼容C,所以读取时效率降低
这个兼容可以设置,在关闭后,发现效率比scanf, printf都要高
关闭C++标准stream(cin, cout, cerr)与C标准程序库文件(stdin, stdout,stderr)的同步,加上这样一行语句即可 ios::sync_with_stdio(false);
效果:
cin, cout,AC需要250ms
scanf, printf,AC需要78ms
加上 ios::sync_with_stdio(false); cin, cout,AC需要62ms


浙公网安备 33010602011771号