字典树
文章平均质量分 60
tomjobs
别慌,慌也没用
展开
-
LeetCode 208. 实现 Trie (前缀树)
Trie(发音类似 “try”)或者说 前缀树 是一种树形数据结构,用于高效地存储和检索字符串数据集中的键。这一数据结构有相当多的应用情景,例如自动补完和拼写检查。 请你实现 Trie 类: Trie() 初始化前缀树对象。 void insert(String word) 向前缀树中插入字符串 word 。 boolean search(String word) 如果字符串 word 在前缀树中,返回 true(即,在检索之前已经插入);否则,返回 false 。 boolean startsWith(S原创 2021-10-11 16:12:59 · 147 阅读 · 0 评论 -
CSUSTOJ 你真的会加法吗?(字典树)
你真的会加法吗? Description 众所周知,LJ精通 1 + 11+1 和 1 + 21+2 , 这天他遇到一个简单的加法题,但这个加法有一个特殊的性质,它是不进位加法, 比如当是10进制时 987 + 643 = 520987+643=520 ,当一位大于 1010 的时候我们我们对其模 1010 ,取余数作为这位的值,kk 进制数同理。 现在给你 nn 个数 (1 \leq n \leq 1e5)(1≤n≤1e5),并且每个数最多只有 1010 位,然后给定一个 kk (2 \leq k \l原创 2020-08-14 09:27:00 · 254 阅读 · 0 评论 -
2020牛客多校第五场 Graph(异或最小生成树)
链接:https://ac.nowcoder.com/acm/contest/5670/B 来源:牛客网 题目描述 Mr. W got a new graph with N vertices and N - 1 edges. It’s a connected graph without cycles. Each edge should have an ugly value. To make the graph more beautiful, Mr. W hope you can help him modif原创 2020-07-26 00:48:33 · 548 阅读 · 0 评论 -
Codeforces 888G. Xor-MST(异或最小生成树)
You are given a complete undirected graph with n vertices. A number a i is assigned to each vertex, and the weight of an edge between vertices i and j is equal to a i xor a j. Calculate the weight of the minimum spanning tree in this graph. Input The first原创 2020-07-26 00:39:57 · 689 阅读 · 0 评论 -
Call from Mendes Gym - 102448C(字典树)
Mendes, as you might already guess, is also a student from UFPE. He is known for having the worst ideas of all. So much that, when anyone gives a bad idea, it’s called a “call from Mendes”. Tired of always falling for Mendes’ calls, his friends decided to原创 2020-06-29 18:35:59 · 372 阅读 · 0 评论 -
Google Kickstart 2020 Round A Bundling(字典树)
Problem Pip has N strings. Each string consists only of letters from A to Z. Pip would like to bundle their strings into groups of size K. Each string must belong to exactly one group. The score of a ...原创 2020-03-22 23:09:51 · 967 阅读 · 0 评论 -
BZOJ3689. 异或之(01字典树第k小)
Description 给定n个非负整数A[1], A[2], ……, A[n]。 对于每对(i, j)满足1 <= i < j <= n,得到一个新的数A[i] xor A[j],这样共有n*(n-1)/2个新的数。求这些数(不包含A[i])中前k小的数。 注:xor对应于pascal中的“xor”,C++中的“^”。 Input 第一行2个正整数 n,k,如题所述。 以下n行...原创 2020-01-27 14:54:31 · 544 阅读 · 0 评论 -
CF1285D. Dr. Evil Underscores(字典树)
Today, as a friendship gift, Bakry gave Badawy ???? integers ????1,????2,…,???????? and challenged him to choose an integer ???? such that the value max1≤????≤????(????????⊕????) is minimum possible, where ⊕ denotes the bitwise XOR o...原创 2020-01-11 22:28:53 · 1169 阅读 · 1 评论 -
Revenge of Fibonacci HDU - 4099(字典树,高精度)
The well-known Fibonacci sequence is defined as following: Here we regard n as the index of the Fibonacci number F(n). This sequence has been studied since the publication of Fibonacci’s book Liber Ab...原创 2019-10-29 16:01:47 · 183 阅读 · 0 评论 -
Spy Syndrome 2 CodeForces - 633C(字典树+dfs)
After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can’t use a cipher as basic and ancient as Caesar cipher. After man...原创 2019-10-28 22:53:05 · 198 阅读 · 0 评论 -
poj3764 AcWing 144. 最长异或值路径
给定一个树,树上的边都具有权值。 树中一条路径的异或长度被定义为路径上所有边的权值的异或和: formula.png ⊕ 为异或符号。 给定上述的具有n个节点的树,你能找到异或长度最大的路径吗? 输入格式 第一行包含整数n,表示树的节点数目。 接下来n-1行,每行包括三个整数u,v,w,表示节点u和节点v之间有一条边权重为w。 输出格式 输出一个整数,表示异或长度最大的路径的最大异或和。 数据范围...原创 2019-08-20 12:18:56 · 274 阅读 · 0 评论 -
143. 最大异或对(字典树)acwing
在给定的N个整数A1,A2……AN中选出两个进行xor(异或)运算,得到的结果最大是多少? 输入格式 第一行输入一个整数N。 第二行输入N个整数A1~AN。 输出格式 输出一个整数表示答案。 数据范围 1≤N≤105, 0≤Ai<231 输入样例: 3 1 2 3 输出样例: 3 难度: 简单 时/空限制: 1s / 64MB 总通过数: 706 总尝试数: 1541 来源: 《算法竞赛进阶...原创 2019-08-19 23:18:51 · 414 阅读 · 2 评论 -
142. 前缀统计 ACwing(字典树模板题)
给定N个字符串S1,S2…SN,接下来进行M次询问,每次询问给定一个字符串T,求S1~SN中有多少个字符串是T的前缀。 输入字符串的总长度不超过106,仅包含小写字母。 输入格式 第一行输入两个整数N,M。 接下来N行每行输入一个字符串Si。 接下来M行每行一个字符串T用以询问。 输出格式 对于每个询问,输出一个整数表示答案。 每个答案占一行。 输入样例: 3 2 ab bc abc abc ef...原创 2019-08-19 22:55:14 · 173 阅读 · 0 评论