2012年2月10日

poj 3481 Double Queue 数据结构 STL

摘要: 题意:定义3种操作1 x y 把编号为x,权值为y的人加入队列2 询问权值最大的人的编号3 询问权值最小的人的编号思路:(1) Splay (2)STL set 1 #include<iostream> 2 using namespace std; 3 #define MAXN 1000001 4 struct node 5 { 6 int left,right,father; 7 int key; 8 int leftnum,rightnum; 9 }; 10 node tree[MAXN]; 11 int root=0; 12 void up... 阅读全文

posted @ 2012-02-10 21:36 myoi 阅读(346) 评论(0) 推荐(0) 编辑

poj 2001 Shortest Prefixes Trie树

摘要: 题意:输入n个字符串,求每个字符串的最短非公共前缀,若没有输出其本身思路:Trie水题 1 #include<iostream> 2 using namespace std; 3 #define MAXL 21 4 #define MAXN 1001 5 struct node 6 { 7 int count; 8 node *next[30]; 9 };10 int n=0;11 node *root;12 int top=0;13 int end_node;14 node memo[MAXN*MAXL];15 void insert(char c[])16 {17 ... 阅读全文

posted @ 2012-02-10 17:58 myoi 阅读(219) 评论(0) 推荐(0) 编辑

poj 3630 Phone List Trie树

摘要: 题意:给一组互不相同的序列,问其中是否有字符串是另一字符串的前缀思路:Trie树水题 1 #include<iostream> 2 using namespace std; 3 #define MAXN 100010 4 struct node 5 { 6 bool end; 7 node *next[10]; 8 }; 9 node *root;10 int top=0;11 bool is_new,ans;12 node memo[MAXN];13 void insert(node *t,char c[],int i)14 {15 if(t->end)16 ... 阅读全文

posted @ 2012-02-10 17:06 myoi 阅读(188) 评论(0) 推荐(0) 编辑

poj 3691 DNA repair AC自动机+DP

摘要: 题意:给定n个疾病DNA序列,和一个待修复序列str。用最小的次数修改待修复序列,使其不含疾病DNA序列。思路:AC自动机+DP建自动机 并加上虚拟节点 每一个节点作为一个dp第二维状态dp[i][j] 表示修复str前i个字符,且当前状态为j的最小修改次数str从1开始 AC自动 树根标号为0 dp[0][0]=0;dp[i+1][j]=min(dp[i+1][j],dp[i][j]+(j代表的当前字符!=str[i+1]))ans=min(ans,dp[m-1][j]); (0<=j<top) top是自动机节点数 1 #include<iostream> 2 us 阅读全文

posted @ 2012-02-10 11:16 myoi 阅读(373) 评论(0) 推荐(0) 编辑

导航