![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字典树
不哭的超人
愿你孤独的努力终有回报,愿你前行的路上有人相伴。
展开
-
Phone List
题目:Phone List 题解:先按照长短从从长到短排序,如果插入一个短的,并且它的结束标志还有的话,就是NO #include <map> #include <stack> #include <queue> #include <vector> #include <cstdio> #include <string> #inc...原创 2020-10-19 15:30:06 · 591 阅读 · 0 评论 -
统计难题
题目:统计难题 题解:按照字典树的方式插入,用val统计每个结点有多少个字符串经过,按照插入的方式查询就好了。 #include <string> #include <cstdio> #include <vector> #include <stack> #include <queue> #include <map> #incl...原创 2020-10-19 15:30:01 · 281 阅读 · 0 评论 -
IMMEDIATE DECODABILITY
题目:IMMEDIATE DECODABILITY 题解:先按照每个字符串的长短从小到大排序,然后依次插入每一个字符串,并且每一个插完之后,做一下标记,如果下一个字符串访问到这个标记,则说明Not #include <string> #include <cstdio> #include <algorithm> #include <iostream> ...原创 2020-10-19 15:29:56 · 532 阅读 · 0 评论 -
Chip Factory
题目:Chip Factory 题解:这题其实用暴力是可以解决的。但我是为了练习01字典树。先将n个数组建成一个01字典树,我是用num数组来统计有多少个数经过某个结点。然后来一个双重循环,计算(a[i]+a[j]),但题目要求i,j,k不能相等,所以需要在上面建的树,将第i个数和第j个数删点,这时候就用num数组了,将经过第i个数和第j个数的结点都进行-1。然后在树中找最大值的时候num[x]为...原创 2020-10-19 15:29:46 · 413 阅读 · 0 评论 -
Xor Sum
题目:Xor Sum 题解:这题运用的是01字典树。是一个模板题。 #include <bits/stdc++.h> using namespace std; const int N = 1e5+10; typedef long long ll; int a[N]; int cnt; int tree[N<<4][2]; int A[N<<4]; //33 ...原创 2020-10-19 15:29:41 · 594 阅读 · 0 评论 -
最大异或对
最大异或对 题解:这题采用的是01字典树,一般这种异或问题都采用的是01字典树树解决。 #include<bits/stdc++.h> using namespace std; const int N = 2e6+1; typedef long long ll; ll a[N]; int cnt = 1; int tree[3*N][2]; void insert(ll y){ ...原创 2020-10-19 15:29:37 · 210 阅读 · 0 评论