【01字典树】hdu-5536 Chip Factory
【题目链接】 http://acm.hdu.edu.cn/showproblem.php?pid=5536 【题意】 求一个式子,给出一组数,其中拿出ai,aj,ak三个数,使得Max{ (ai+aj) ^ ak } 【题解】 其实这里就需要大家做一个删除的操作; 类似于dfs的恢复现场的操作即可。 【代码】 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N = 1e5+10; 6 int Son[N*31][2]; 7 int a[N],idx; 8 int Cnt[N*31]; 9 void Insert( int x ){ 10 int p = 0 ; 11 for(int i=30;~i;i--){ 12 int t = x >> i & 1 ; 13 if( !Son[p][t] ){ 14 Son[p][t] = ++idx; 15 } 16 p = Son[p][t]; 17 Cnt[p] ++ ; 18 } 19 } 20 void Delete( int x ){ 21 int p = 0 , tmp ; 22 for(int i=30;~i;i--){ 23 int t = x >> i & 1 ; 24 if(