有个代码,交到 OJ 上报 TLE,后来开 ubsan 跑了跑报了 RE。
for(int i=0;i<k;++i) for(int j=i+1;j<k;++j)
{
int x=pos[o][i],y=pos[o][j];
if(x>y) swap(x,y);ll POS=F(x,y);
if(H.find(POS)!=H.end())
P[H[POS]].push_back(o);
}
/usr/include/c++/9/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp:530:15: runtime error: member access within null pointer of type 'struct entry'
其中定义了 cc_hash_table <ll,int> H,在执行 H.find(POS)!=H.end() 时报的 RE,直接换成 unordered_map 就没事了。