常见 Tricks

· · 个人记录

Luogu

是时候总结一下 Trick 了,无论是考前复习还是日常巩固都相当重要。

这个帖子主要记录的是一些 idea,少部分是考试注意事项。

部分语言截取自之前的博客所以可能会有点突兀。

首先上一句真理:

\text{远古}

\text{Weekly * Round}

总结至 R10。

\text{10.6}

\text{10.8}

\text{10.9}

\text{10.12}

\text{10.14}

\text{10.16}

首先在程序开头定义一个 bool 变量 Flag,然后在主函数末尾定义一个 bool 变量 EndFlag。程序结束时输出 (&EndFlag - &Flag) / 1024.0 / 1024.0 即使程序占用空间(单位为 MB)。(注意不要开 O2)就像这样:

#include <bits/stdc++.h>
using namespace std;
bool Flag;
/*

*/
signed main() {
    /*

    */
    bool EndFlag;
    cout << (&EndFlag - &Flag) / 1024.0 / 1024.0;
    return 0;
}

10.17

10.19

10.20

\text{CSP}

\text{策略}

\text{Trick}

10.26

10.28

\text{11.5}

\text{11.6}

\text{停课期间}

void add(int id) {
    cnt[a[id]] ++; 
    while(cnt[mex + 1]) mex++;
}
void del(int id) {
    cnt[a[id]] --;
    if(!cnt[a[id]] and a[id] >= 0) mex = min(mex, a[id] - 1);
    while(!cnt[mex] and mex >= 1) mex --;
}

\text{别人提供的 Trick}

先放上几篇其它大佬的 Trick。1 2