voidinsert(LL val){ for (int i = BIT; i >= 0; i--) { if ((1ll << i) & val) { if (base[i] == 0) { base[i] = val;; break; } else val ^= base[i]; } } }
𝕚𝕟𝕒𝕩𝕦𝕖𝕣𝕪
贪心思想
query_min_max.cpp
1 2 3 4 5 6 7 8 9
LL query_min(){ for (int i = 0; i <= BIT; i++) if (base[i]) return base[i]; return0; } LL query_max(){ LL res = 0; for (int i = BIT; i >= 0; i--) if ((res ^ base[i]) > res) res ^= base[i]; return res; }
voidrebuild(){ for (int i = BIT; i >= 0; i--) for (int j = i - 1; j >= 0; j--) if (base[i] & (1ll << j)) base[i] ^= base[j]; for (int i = 0; i <= BIT; i++) if (base[i]) p[cnt++] = base[i]; } intquerykth(int k){ int res = 0; if (k >= (1ll << cnt)) return0x3f3f3f3f; for (int i = BIT; i >= 0; i--) if (k & (1ll << i)) { res ^= p[i]; } return res; }
The End
「Ô mon âme, n'aspire pas à la vie immortelle, mais épuise le champ du possible.」