缺省源

· · 个人记录

快读

#ifdef ONLINE_JUDGE
static char buf[1000000],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++
#endif

inline int read(){
    register int x = 0;
    register char c = getchar();
    for(;c < '0' || c > '9';c = getchar());
    for(;c >= '0' && c <= '9';c = getchar())
        x = x * 10 + (c ^ '0');
    return x;
}

完整版

const int SIZ = 1000000;
namespace IO{ // by OneZzz6174
    #ifdef ONLINE_JUDGE
    static char buf[SIZ],*A=buf,*B=buf;
    #define getchar() A==B&&(B=(A=buf)+fread(buf,1,SIZ,stdin),A==B)?EOF:*A++
    #endif
    static char obuf[SIZ],*C=obuf;
    #define putchar(x) (C-obuf<SIZ)?(*C++=x):(fwrite(obuf,C-obuf,1,stdout),C=obuf,*C++=x)
    inline int read(){
        register int x=0,f=1,c=getchar();
        for(;c<48||c>57;c=getchar())if(c=='-')f=-1;
        for(;c>47&&c<58;c=getchar())x=x*10+(c^48);
        return x*f;
    }
    inline void read(char &c){do{c=getchar();}while(c==' '||c =='\n');}
    inline int readc(){return getchar();}
    template<typename Int>
    inline void print(Int x){
        if(x<0)putchar(45),x=-x;
        if(x>9)print(x/10);putchar(x%10+48);
    }
    inline void print(char c){putchar(c);}
    inline void print(const char *s){for(char *p = (char*)s;*p;++p)putchar(*p);}
    inline void flush(){fwrite(obuf,C-obuf,1,stdout),C=obuf;}
}
using IO::read;
using IO::readc;
using IO::print;
using IO::flush;

舒适版

const int SIZ = 1000000;
namespace IO{ // by OneZzz6174
#ifdef ONLINE_JUDGE
    static char buf[SIZ],*A=buf,*B=buf;
    #define getchar() A==B&&(B=(A=buf)+fread(buf,1,SIZ,stdin),A==B)?EOF:*A++
#endif
    static char obuf[SIZ],*C=obuf;
    #define putchar(x) (C-obuf<SIZ)?(*C++=x):(fwrite(obuf,C-obuf,1,stdout),C=obuf,*C++=x)
    inline void flush(){fwrite(obuf,C-obuf,1,stdout),C=obuf;}
    struct FLS{~Fls(){fwrite(obuf,C-obuf,1,stdout);}}fls;
    inline int read(){
        register int x=0,f=1,c=getchar();
        for(;c<48||c>57;c=getchar())if(c=='-')f=-1;
        for(;c>47&&c<58;c=getchar())x=x*10+(c^48);
        return x*f;
    }
    inline void read(int &x){x=read();}
    inline void read(char &c){do{c=getchar();}while(c==' '||c =='\n');}
    inline int readc(){return getchar();}
    template<typename Int>
    inline void print(Int x){
        if(x<0)putchar(45),x=-x;
        if(x>9)print(x/10);putchar(x%10+48);
    }
    inline void print(char c){putchar(c);}
    inline void print(const char *s){for(char *p = (char*)s;*p;++p)putchar(*p);}
    template<typename _Tp,typename... _Args>
    inline void read(_Tp& x,_Args&... args){read(x);read(args...);}
    template<typename _Tp,typename... _Args>
    inline void print(_Tp x,_Args... args){print(x);print(args...);}
}
using IO::read,IO::readc,IO::print,IO::flush;

debug printer

namespace Debug{ // by OneZzz6174
    #ifdef ONLINE_JUDGE
    #define db_pc(c)
    #else
    #define db_pc(c) printf("%c",c)
    #endif
    inline void db_print(int x){
        if(x<0){db_pc(45);x=-x;}
        if(x>9)db_print(x/10);db_pc(x%10+48);
    }
    inline void db_print(char c){db_pc(c);}
    inline void db_print(const char *s){for(char *p = (char*)s;*p;++p)db_pc(*p);}
    template<typename _Tp,typename... _Args>
    inline void db_print(_Tp x,_Args... args){db_print(x);db_print(args...);}
}

using Debug::db_print;

缺省源

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<vector>

#define rint register int
#define IL inline

namespace QSY{
const int SIZ = 1000000;
namespace IO{ // by OneZzz6174
#ifdef ONLINE_JUDGE
static char buf[SIZ],*A=buf,*B=buf;
#define getchar() A==B&&(B=(A=buf)+fread(buf,1,SIZ,stdin),A==B)?EOF:*A++
#endif
static char obuf[SIZ],*C=obuf;
#define putchar(x) (C-obuf<SIZ)?(*C++=x):(fwrite(obuf,C-obuf,1,stdout),C=obuf,*C++=x)
inline void flush(){fwrite(obuf,C-obuf,1,stdout),C=obuf;}
struct FLS{~FLS(){fwrite(obuf,C-obuf,1,stdout);}}fls;
inline int read(){
    register int x=0,f=1,c=getchar();
    for(;c<48||c>57;c=getchar())if(c=='-')f=-1;
    for(;c>47&&c<58;c=getchar())x=x*10+(c^48);
    return x*f;
}
template<typename Int>
inline void read(Int &x){
    x = 0; register int f=1,c=getchar();
    for(;c<48||c>57;c=getchar())if(c=='-')f=-1;
    for(;c>47&&c<58;c=getchar())x=x*10+(c^48); x*=f;
}
inline void read(char &c){do{c=getchar();}while(c==' '||c =='\n');}
inline int readc(){return getchar();}
template<typename Int>
inline void print(Int x){
    if(x<0)putchar(45),x=-x;
    if(x>9)print(x/10);putchar(x%10+48);
}
inline void print(char c){putchar(c);}
inline void print(const char *s){for(char *p = (char*)s;*p;++p)putchar(*p);}
template<typename _Tp,typename... _Args>
inline void read(_Tp& x,_Args&... args){read(x);read(args...);}
template<typename _Tp,typename... _Args>
inline void print(_Tp x,_Args... args){print(x);print(args...);}
}using IO::read;using IO::readc;using IO::print;
#define rep(i,a,b) for(int i = (a);i <= (b);++i)
#define Rep(i,a,b) for(int i = (a);i >= (b);--i)
}using namespace QSY;

namespace Debug{
    #ifdef ONLINE_JUDGE
    #define db_pc(c)
    #else
    #define db_pc(c) printf("%c",c)
    #endif
    IL void db_print(int x){
        if(x<0){db_pc(45);x=-x;}
        if(x>9)db_print(x/10);db_pc(x%10+48);
    }
    IL void db_print(char c){db_pc(c);}
    IL void db_print(const char *s){for(char *p = (char*)s;*p;++p)db_pc(*p);}
    template<typename _Tp,typename... _Args>
    IL void db_print(_Tp x,_Args... args){db_print(x);db_print(args...);}
}

using Debug::db_print;

namespace FUNC{
    IL bool range(rint x,rint l,rint r){ return l<=x&&x<=r; }
    IL bool range(rint a,rint b,rint l,rint r){ return l<=a&&b<=r; }
    IL int max2(rint a){ return a; }
    IL int min2(rint a){ return a; }
    IL int max2(rint a,rint b){ return a>b?a:b; }
    IL int min2(rint a,rint b){ return a<b?a:b; }
    IL int chkmax(rint &a,rint b){ return a=a>b?a:b; }
    IL int chkmin(rint &a,rint b){ return a=a<b?a:b; }
    template<typename... _Args>
    IL int max2(rint x,_Args&... args){return max2(x,max2(args...));}
    template<typename... _Args>
    IL int min2(rint x,_Args&... args){return min2(x,min2(args...));}
    IL void swap2(rint &x,rint &y){ x^=y^=x^=y; }
}

using namespace FUNC;

int main(){

    return 0;
}