#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int tree[N * 2][2];
int cnt = 0,len;
void build(int x) {
int u = 0, p = 1 << len;
for (int i = 0; i <= len; i++,p >>= 1)
u = (tree[u][!!(x & p)]? tree[u][!!(x & p)]:tree[u][!!(x & p)]=++cnt);
}
int find(int x) {
int u = 0,sum=0,p=1<<len;
for (int i = 0; i <= len; i++, p >>= 1) {
if (tree[u][!!(x & p)])
u = tree[u][!!(x & p)], sum += (!!(x & p)) * p;
else if (tree[u][1])u = tree[u][1], sum += p;
else u = tree[u][0];
}
return sum;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
/*int t;
cin >> t;
while(t--)*/
solve();
return 0;
}
01字典树模板
最新推荐文章于 2024-09-11 20:39:26 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)