Codeforces 856B - Similar Words】的更多相关文章

856B - Similar Words 题意 如果一个字符串可以通过去掉首位字母得到另一个字符串,则称两个字符串相似. 给出一个字符串集合,求一个新的字符串集合,满足新集合里的字符串是原字符串集合中的字符串的前缀且字符串两两不相似,问新集合里字符串的最大数量. 分析 注意到字符串都是基于原串的前缀,考虑用 \(Trie\) 优化,可以高效存储所有的前缀串.考虑相似的定义,一个较长串的相似串是可以唯一确定的(去掉首字母),通过这个关系,我们可以把两个字符串连边,最终我们可以构造出一棵树,考虑题目…
题目链接:https://codeforces.com/contest/1090/problem/D Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these…
题目链接: http://codeforces.com/contest/1257/problem/F 题意: 给出$n$个30位整数 找到一个数,让它与这$n$个数分别异或,得到的$n$个数二进制1的个数相同 数据范围: $1\leq n \leq 100$ 分析: CF官方题解称这是中间相遇技巧 枚举答案的低15位,这时有$2^{15}$种情况 与给出的$n$个数的低15位去异或,得到1的数量定义为$low[i]$ 把$(low[2]-low[1],low[3]-low[1],.....low…
图给得很良心,一个s到t的有向图,权值至少为1,求出最短路,如果是一定经过的边,输出"YES",如果可以通过修改权值,保证一定经过这条边,输出"CAN",并且输出最小修改值,否则输出"NO".保证有s到t的路径,可能有重边. 建正反两个图,分别求出s和t的最短路径,用来判断一条边是不是在最短路径上,然后把最短路径取出来建一个图求割边. 不要用spfa,最坏O(VE),(出卡spfa数据的方法:Hard Test),会TLE 109(数据好啊),自…
题意: 给你n个数字(<230),求出一个数字使得所有数字^这个数字之后,二进制状态下的1的个数相同. 解析: 因为最大数字二进制数有30位,所以分为前15位和后15位,分别枚举0-1<<15,用map匹配. 代码: #include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include <vector> #include &…
Error Correct System Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 527B Description Ford Prefect got a job as a web developer for a small company that makes towels. His current work ta…
Escape Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 148B Description The princess is going to escape the dragon's cave, and she needs to plan it carefully. The princess runs at vp mil…
B. War of the Corporations 题目连接: http://www.codeforces.com/contest/625/problem/B Description A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the…
Rock-Paper-Scissors 题目连接: http://codeforces.com/problemset/problem/173/A Description Nikephoros and Polycarpus play rock-paper-scissors. The loser gets pinched (not too severely!). Let us remind you the rules of this game. Rock-paper-scissors is play…
B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/556/problem/B Description Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famou…