poj 3464(Trie)Approximations】的更多相关文章

Approximations Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 419   Accepted: 23 Description For any decimal fraction, we can obtain a set of approximations of different accuracy by mean of rounding. Take 0.2503 for example, we have th…
题目链接:http://poj.org/problem?id=1816 思路:建好一颗Trie树,由于给定的模式串可能会重复,在原来定义的结构体中需要增加一个vector用来记录那些以该节点为结尾的字符串的序号,然后就是匹配的过程了,需要注意的是,对于‘?'和'*',每一次都是可以匹配的,并且对于'*',还得枚举所需要匹配的长度(从0开始).由于最后的答案可能会有重复,一开始我没有判断时候有重复的,WA了好多次=.=!!. #include <iostream> #include <cs…
用记录附加信息的val数组记录次数即可. trie的原理:每个可能出现的字目给一个编号c,那么整个树就是一个c叉树 ch[u][c]表示 节点u走c边过去之后的节点 PS:trie树还有种动态写法,使用指针和动态分配内存代替了连续的ch数组,更加节省内存. Reference:http://blog.csdn.net/architect19/article/details/8966247 #include <cstdio> #include <cstring> #include &…
第一道trie 还需要写题来建立自己的代码习惯. #include <cstdio> #include <vector> #include <algorithm> #define maxn 20010 using namespace std; struct node { char v; int sz; bool isword, mark; node *son[], *pre; }pool[maxn], *tail=pool, *null=pool; ]; struct…
Phone List Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26559 Accepted: 8000 Description Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogue li…
Find the Clones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 7704 Accepted: 2879 Description Doubleville, a small town in Texas, was attacked by the aliens. They have abducted some of the residents and taken them to the a spaceship orbi…
Phone List Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 29416   Accepted: 8774 Description Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogu…
生无可恋 查RE查了一个多小时.. 原因是我N define的是250500 应该是500500!!!!!!!!! 身败名裂,已无颜面对众人.. 吐槽完了 我们来说思路... 思路: 判有向图能否形成欧拉路 但是他给的是string,怎么转化成int呢? trie树! 这东西有多么优美我就不说了... 反正写起来不难. 具体的请见代码吧 // by SiriusRen #include <bitset> #include <cstdio> #define N 500500 usin…
ACM Computer Factory Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4829 Accepted: 1641 Special Judge Description As you know, all the computers used for ACM contests must be identical, so the participants compete on equal terms. That is…
Phone List Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 25280   Accepted: 7678 Description Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogu…