版本比较
串串学习笔记
正文
增加 42 行删除 0 行
250 行未改动全部展开251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296250 行未改动全部展开 while (T--) Solution::Main(); return 0;}```下面给出 01trie 的模版:```cppconst int N = 3e6 + 5;namespace trie { constexpr int H = 21; int ch[N * (H + 1)][2], w[N * (H + 1)], xorv[N * (H + 1)]; int tot = 0; inline int mknode() { ++tot; ch[tot][1] = ch[tot][0] = w[tot] = xorv[tot] = 0; return tot; } inline void maintain(int o) { w[o] = xorv[o] = 0; if (ch[o][0]) { w[o] += w[ch[o][0]]; xorv[o] ^= xorv[ch[o][0]] << 1; } if (ch[o][1]) { w[o] += w[ch[o][1]]; xorv[o] ^= (xorv[ch[o][1]] << 1) | (w[ch[o][1]] & 1); } w[o] = w[o] & 1; } inline void insert(int& o, int x, int dep) { if (!o) o = mknode(); if (dep > H) return (void)(w[o]++); insert(ch[o][x & 1], x >> 1, dep + 1); maintain(o); } inline void erase(int o, int x, int dep) { if (dep > 20) return (void)(w[o]--); erase(ch[o][x & 1], x >> 1, dep + 1); maintain(o); } inline void addall(int o) { swap(ch[o][0], ch[o][1]); if (ch[o][0]) addall(ch[o][0]); maintain(o); }}```