唐 B 错误合集
-
写对拍的时候使用
rand()但是并没有加srand(time(0))。这样导致了模拟赛第一题拍了 2w+ 组但是并没有发现任何错误,浪费 2h。
所以使用mt19937 rnd(time(0) ^ (*new unsigned int));作为随机数。$\text{Update}\ \text{On} \ \text{Sept.23, \ 2026}$
-
写线段树的时候没有调用
Tree.build(1, 1, n);导致程序一直 RE。$\text{Update}\ \text{On} \ \text{Sept.28, \ 2026}$
-
写线段树懒标记下传的时候,记得把当前节点的标记清空。
$\text{Update}\ \text{On} \ \text{Oct.1, \ 2026}$
-
交代码的时候一定要再跑一遍,确认调试信息有没有删干净。
$\text{Update}\ \text{On} \ \text{Oct.1, \ 2026}$
-
写并查集维护连通块大小时一定要调用
dsu.init()进行初始化。
struct DSU {
int fa[MAXN], siz[MAXN];
void init() {
for (int i = 1; i <= n; i++) fa[i] = i, siz[i] = 1;
}
int get(int x) {
return fa[x] = fa[x] == x ? x : get(fa[x]);
}
bool merge(int x, int y) {
int fax = get(x), fay = get(y);
if (fax == fay) return 0;
fa[fay] = fax, siz[fax] += siz[fay];
return 1;
}
} dsu;
$\text{Update}\ \text{On} \ \text{Oct.2, \ 2026}$
-
对于
unsigned long long右移 64 位是 未定义行为。不同的编译器可能产生不同结果:有的可能不移位(返回原值),有的可能返回 0,有的可能崩溃。这会导致答案随机错误,从而 WA。$\text{Update}\ \text{On} \ \text{Oct.8, \ 2026}$
-
不要盲目相信 CPH-NG 的 Special Judge 的返回结果,题目给的 SPJ 可能是假的。
$\text{Update}\ \text{On} \ \text{Oct.22, \ 2026}$
-
多测一定要清空。
$\text{Update}\ \text{On} \ \text{Oct.22, \ 2026}$
-
矩阵乘法没有交换律
$\text{Update}\ \text{On} \ \text{Oct.29, \ 2026}$

浙公网安备 33010602011771号