为什么?这是为什么嘞!
查看原帖
为什么?这是为什么嘞!
414386
Isshiki·Iroha楼主2021/10/12 10:05

这个题我 TLE 了几十发,发现 TLE 的原因如下

    char buf[1<<18],*p1=buf,*p2=buf;
    inline int getc() {
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<18,stdin),p1==p2)?EOF:*p1++;
    }
#ifndef ONLINE_JUDGE
    #define getc() getchar()
#endif
    template<typename T>inline void read(T& x) {
        x=0;int f=1;
        char ch=getc();
        while(!isdigit(ch)){if(ch=='-')f=~f+1;ch=getc();}
        while (isdigit (ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getc();}
        x*=f;
    }
    template <typename T,typename... Args> inline void read(T& x, Args&... args) {
        read(x);
        read(args...);
    }

我后面把 ifndef 换成 ifdef 就过了,也就是不用手写的 getc() 但是我记得 fread 更快呀?求大佬解释

2021/10/12 10:05
加载中...