求教教 cc_hash_table RE
  • 板块学术版
  • 楼主int_R
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/10/31 14:20
  • 上次更新2024/10/31 19:16:42
查看原帖
求教教 cc_hash_table RE
469312
int_R楼主2024/10/31 14:20

有个代码,交到 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 就没事了。

2024/10/31 14:20
加载中...