【01.13更新】更"人性化"、更"好记忆"的缺省源

· · 闲话

Page Views Count: (从\tt{2025-10-05}重新开始计数)

\color{darkblue}\LARGE{\boldsymbol{\underline{-Updates-}}}\newline\color{grey}{\scriptsize{\bf{更新日志}}} \newline\newline

写在代码前

  • 在编写本缺省源的过程中,作者不断尝试新的写法,也因此出现了很多常见的错误。作者通过一段时间的积累,将这些错误列成一个列表,以起到警示后人之作用。
  • 本文的快读/快写的实现速度并非最快,如有需要,可以参考我的这篇文章,或这位dalao的文章。
  • 【\tt{2025-01-13} 已删】代码1-82行的头文件来自于bits/stdc++.h,可以等效替代。此处列出是因为一部分计算不支持直接#include该头文件的写法。
  • 解释一下:常数L(19行)后的 注释( // L!=1e9+10)是为纪念CSP-J 2023中因数组开1\text{e}9+10而爆零的笔者。 警示笔者本人
  • 本文可能存在一些错误,如发现,请发送在评论区并私信作者。\newline\newline
#include <bits/stdc++.h>

#ifdef _WIN32
    #define getchar_unlocked getchar
    #define putchar_unlocked putchar
#else
    #define getchar getchar_unlocked
    #define putchar putchar_unlocked
#endif

// #define x first
// #define y second
#define set(arr,val) memset((arr),(val),sizeof(arr))
// constexpr signed L=; // L!=1e9+10

typedef long long LL;
// typedef unsigned long long ULL;
// typedef std::pair<signed,signed> PII;
// typedef std::priority_queue<int,std::vector<int>,std::greater<int> > P_Q;
// typedef std::priority_queue<int,std::vector<int>,std::less<int> > _P_Q;
// typedef __int128 INT

// constexpr signed N=;
// constexpr signed M=;
// #include <numbers> // only in C++20
constexpr signed inf=0x3f3f3f3f;
constexpr signed err=-1;
constexpr double eps=1e-8;
const double pi=acos(-1.0);
constexpr signed dx[]={0, 0, 1,-1, 1, 1,-1,-1};
constexpr signed dy[]={1,-1, 0, 0, 1,-1,-1, 1};
// constexpr LL mod=1e9+7;

using namespace std;

template<typename T>
void debug(string name="(NaN)",vector<T> v={-1})
{
    cout<<"\n***"<<name<<"***\n";
    for(typename vector<T>::const_iterator it=v.begin();it!=v.end();it++)
        cout<<*it<<' ';
    cout<<"\n****************\n";
}

inline LL read()
{
    signed f=1;
    LL x=0;
    char c=getchar_unlocked();

    while(c<'0'||c>'9')
    {
        if(c=='-')
            f=-1;
        c=getchar_unlocked();
    }

    while('0'<=c&&c<='9')
    {
        x=(x<<3)+(x<<1)+(c^48);
        c=getchar_unlocked();
    }

    return f*x;
}

inline void _write(LL x)
{
    if(x<0)
    {
        putchar_unlocked('-');
        x=-x;
    }
    if(x>9)
        _write(x/10);
    putchar_unlocked(x%10+'0');

    return;
}

inline void write(LL x,short op=0)// op>0:x+Space;op==0:x+endl;op<0:x.
{
    _write(x);
    if(op==0)
        putchar_unlocked('\n');
    else if(op>0)
        putchar_unlocked(' ');
    return;
}

inline void write_s(string s)
{
    signed len=s.size();
    for(signed i=0;i<len;i++)
        putchar_unlocked(s[i]);
}

// #define CONSOLE_DEBUG
// #define FILENAME "sample"
signed main()
{
    #ifndef ONLINE_JUDGE
        #ifndef CONSOLE_DEBUG
            freopen(FILENAME".in","r",stdin);
            freopen(FILENAME".out","w",stdout);
        #endif
    #endif



    return 0;
}

为了卡常,我真的尽力了...

完结撒花~ | \color{darkred}{\small\textsf{返回顶部}\normalsize\Uparrow}