版本比较
「2019冬令营提高组」密文
正文
增加 6 行删除 6 行
69 行未改动707172737474757677787980818283838485868788898990919293949596969798989910010110210310410510610710710810911011127 行未改动69 行未改动 root=tre[root][1]; } else { if(!tre[root][0]) if(!tre[root][0]) { tre[root][0]=++tot; G[i].push_back(tre[root][0]); } root=tre[root][0]; } } fro[root]=x;} }IL void dfs(ll lc,ll rc){// printf("now at %lld and %lld\n",lc,rc); if(!tre[lc][0]&&!tre[lc][1]) {//我们取最小的一条边连通
minn=min(minn,sum[fro[lc]]^sum[fro[rc]]); return; } if(tre[lc][0]) {//01Trie树上的贪心 if(tre[rc][0]) dfs(tre[lc][0],tre[rc][0]); else dfs(tre[lc][0],tre[rc][1]); else dfs(tre[lc][0],tre[rc][1]); }
if(tre[lc][1]) { if(tre[rc][1]) dfs(tre[lc][1],tre[rc][1]); else dfs(tre[lc][1],tre[rc][0]); }}IL void getans(ll now){ minn=999999999999999LL; minn=999999999999999LL; dfs(tre[now][0],tre[now][1]); ans+=minn;// dfs(tre[now][1],tre[now][0]);}27 行未改动