题目链接:https://cn.vjudge.net/problem/LightOJ-1224 Given a set of $n$ DNA samples, where each sample is a string containing characters from {A, C, G, T}, we are trying to find a subset of samples in the set, where the length of the longest common prefix…
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=121897#problem/F F - DNA Prefix Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Description Given a set of n DNA samples, where each sample is a string con…
Given a set of n DNA samples, where each sample is a string containing characters from {A, C, G, T}, we are trying to find a subset of samples in the set, where the length of the longest common prefix multiplied by the number of samples in that subse…
牛客wannafly 挑战赛14 B 前缀查询(trie树上dfs序+线段树) 链接:https://ac.nowcoder.com/acm/problem/15706 现在需要您来帮忙维护这个名册,支持下列 4 种操作: 插入新人名 si,声望为 a 给定名字前缀 pi 的所有人的声望值变化 di 查询名字为 sj 村民们的声望值的和(因为会有重名的) 查询名字前缀为 pj 的声望值的和 题解:一个非常明显的线段树操作,前缀可以看作是区间更新,区间查询,给定名字就是单点更新,单点查询,字典树上…
题目链接: http://poj.org/problem?id=1816 http://bailian.openjudge.cn/practice/1816?lang=en_US Time Limit: 2000MS Memory Limit: 65536K Description A word is a string of lowercases. A word pattern is a string of lowercases, '?'s and '*'s. In a pattern, a '…
题意: 给你两个序列a,b,序列c的某位是由序列a,b的此位异或得来,让你重排序列ab,找出字典序最小的序列c. 题解: 如果能找到a,b序列中完全一样的值当然最好,要是找不到,那也尽量让低位不一样. 因此,将两个序列中元素的二进制视作字符串,建字典树. 在两棵字典树上,贪心地找让当前位一样的. 每找c的一位,dfs一遍,dfs过程中剪掉已经因为构造c而用掉的子树,构造序列c. 然后爆wa... 我造了好几组测例,发现贪心并不能找出当前位的最优解,比如dfs到两棵字典树上的某个点,这两个节点都既…
Kuro is living in a country called Uberland, consisting of nn towns, numbered from 11to nn, and n−1n−1 bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects two towns aa and bb. Kuro loves wa…
题目描述 小Q正在设计一种棋类游戏.在小Q设计的游戏中,棋子可以放在棋盘上的格点中.某些格点之间有连线,棋子只能在有连线的格点之间移动.整个棋盘上共有V个格点,编号为0,1,2…,V-1,它们是连通的,也就是说棋子从任意格点出发,总能到达所有的格点.小Q在设计棋盘时,还保证棋子从一个格点移动到另外任一格点的路径是唯一的.小Q现在想知道,当棋子从格点0出发,移动N步最多能经过多少格点.格点可以重复经过多次,但不重复计数. 输入 第一行包含2个正整数V,N,其中V表示格点总数,N表示移动步数. 接下…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1232 题意: 给你一个无向图,n个点,m条边. 每条边有边权len[i][j],每个点有点权c[i]. 让你找一棵生成树,并在这棵树上找一个根. 从根开始dfs整棵树,每经过一条边(或一个点),花费加上对应的边权(点权). 问你最小的花费. 题解: 树上dfs性质: 花费 = ∑ (2*len[i][j] + c[i] + c[j]) + c[root] (1)每一条边要经过两次. (2…
T9 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2747    Accepted Submission(s): 1029 Problem Description A while ago it was quite cumbersome to create a message for the Short Message Service…