本文会持续更新
以下题号均为洛谷题号
1.轻易不要调用 函数和
函数,会丢精度。还是老老实实写快速幂吧,写
比
好。比如 P1351,我用
连样例都过不了(或者说我太菜了)
(num2 += w[e[j].v] * w[e[j].v]) %= mod;
// (num2 += pow(w[e[j].v],2)) %= mod;这行代码(pow)会导致精度问题,慎用
2.建图时如果节点很多,比如 (N为点数)而内存限制为
时,不要用
存图!会 MLE。比如 P2403,我用
就 MLE 过不了,用链式前向星直接 AC 。
struct graph{
int head[MAX],tot;
struct edge{
int v,nxt;
}e[MAX];
inline void add(int u,int v){
e[++tot] = (edge){v,head[u]};
head[u] = tot;
}
}g,f;//链式前向星
vector <int> g[MAX],f[MAX];
3. 类型不能用
scanf("%d",&b);
输入,本人 P4782 因为这个被硬控了4次爆零。
4.如果你关了流,请不要用快写输出,会 (至少在洛谷评测机上无法输出
inline void write(ll x){
if(x / 10) write(x / 10);
putchar((x % 10 + '0'));
}
……
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
本人因此 P5283 三次爆零
5.唐诗错误
(1) 不要在点双之间连边(恐怕只有我一个人会这么唐)P3225
可以在强连通分量、边双之间连边,点双只能统计割点
(2) 在边双之间连边时注意不要建双向边!!!
跑完 出环了…… 例如:P2783
6.不要这样写:
a[++tot].pos = a[tot-1].pos + 1,a[tot].d = -1;