大意: 给定字符串集$S$, 每次询问给出字符串$a$, 求$S$中是否存在一个字符串恰好与$a$相差一个字符. 直接建字典树暴力复杂度是$O(n\sqrt{n})$, 也可以用set维护所有哈希值, 只更改一个字符的话可以O(1)计算哈希值, 复杂度$O(nlogn)$…
Time Limit: 5000MS   Memory Limit: 128000K Total Submissions: 27704   Accepted: 7336 Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line suc…
E - Petya and Exam CodeForces - 832B 这个题目其实可以不用字典树写,但是因为之前写过poj的一个题目,意思和这个差不多,所以就用字典树写了一遍. 代码还是很好理解的,主要就是哪个findx函数,这个要好好理解. 如果碰到*或着?就要重新标记一下,其他都是一样的,对于?可以跳过好字母,对于*可以跳过若干个不好的字母, 这个就在直接跳过之前加一个判断条件就可以了. 贴一下代码 #include<iostream> #include<cstdio> #…
C. Watto and Mechanism time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a ce…
题意: Today at the lesson Vitya learned a very interesting function - mex. Mex of a sequence of numbers is the minimum non-negative number that is not present in the sequence as element. For example, mex([4, 33, 0, 1, 1, 5]) = 2 and mex([1, 2, 3]) = 0.…
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6700 Accepted: 1922 Description RJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The layout of the lines is shown in…
Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 29059 Accepted: 12565 Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary…
题目:http://poj.org/problem?id=2513 参考博客:http://blog.csdn.net/lyy289065406/article/details/6647445 http://www.cnblogs.com/LK1994/p/3263462.html #include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stac…
题目链接  Watto and Mechanism 题意  给出$n$个串(相当于字典),然后给出$m$个询问. 每个询问以字符串的形式给出,你需要改变这个字符串中的任意一个字符 (必须改变且只能改变一个) 如果改变之后可以成为$n$个串中的一个字符串,则输出$YES$, 否则输出$NO$. 字母集合为$\left\{ a, b, c \right\}$ 考虑字典树. 首先把$n$个单词插入字典树中. 询问的时候用$dfs$,$flag$表示搜索到当前是否已经改变过一个字符. 如果已经改变过那只…
[题目链接]:http://codeforces.com/contest/514/problem/C [题意] 给你n个字符串; 然后给你m个询问;->m个字符串 对于每一个询问字符串 你需要在n个字符串里面找到和它的长度相同,且只有一个位置的字符不同的字符串; 或者告知这是不存在的; [题解] 写个字典树; 在每一位多了两种选择; (即更改这个字符) 然后前面已经确定匹配的不要重新匹配;->不然会超时 有改和不改两种可能. 注意最后必须要改一个字符. 字典树以后还是用0作为根节点吧.不然to…