fasterReader

快速读入,仿cin格式

使用c++ template实现类型识别

namespace FasterReader
{
    char ch;
    int op;
    template <typename T>
    inline void _FasterReader(T &x)
    {
        for (op = 1, ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
            if (ch == '-')
                op = -1;
        for (x = 0; ch >= '0' && ch <= '9'; ch = getchar())
            x = x * 10 + (ch & 15);
        x *= op;
    }
    template <>
    inline void _FasterReader<char>(char &s)
    {
        for (s = getchar(); s <= ' '; s = getchar())
            ;
    }
    inline void _FasterReader(char *s)
    {
        for (ch = getchar(); ch <= ' '; ch = getchar())
            ;
        for (; ch > ' '; ch = getchar())
            *s++ = ch;
        *s = 0;
    }
    inline void _FasterReader(string &s)
    {
        for (ch = getchar(); ch <= ' '; ch = getchar())
            ;
        for (s.clear(); ch > ' '; ch = getchar())
            s.push_back(ch);
    }
    inline void FRead() {}
    template <typename T, typename... Args>
    inline void FRead(T &x, Args &... args)
    {
        _FasterReader(x);
        FRead(args...);
    }
    class FasterCin
    {
    public:
        template <typename T>
        FasterCin &operator>>(T &other)
        {
            FRead(other);
            return *this;
        }
    } fasterCin;
#define fcin FasterReader::fasterCin
#define READ(...) FasterReader::FRead(__VA_ARGS__)
} // namespace FasterReader