摘要: 典型的字典树使用一个flag来标记是否是一个句子。现在我们可以用一个cout来标记这条路径是否有单词存在过,存在过几次连接http://poj.org/problem?id=2001View Code #include <iostream>#include<stdio.h>#include<stdlib.h>#include<string.h>using namespace std;struct node{ int count;//用来存有多少个单词存在过。 int next[27];}word[20100];int num = 0;char s 阅读全文
posted @ 2012-07-26 17:45 某某。 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 这道题根同性恋那道题相当像无非就是看他有没有合并过、记录合并之后的那个点的关系罢了。View Code //AC代码1#include <stdio.h> #include <stdlib.h> int set[100005],num[100006],h[100005]; int find(int x) { if(x!=set[x]) { int y = set[x]; set[x] = find(set[x]); num[x] = (num[x]+num[y])%2;//一定要写这个%2不知道为什么不加%2他就wa加上就ac我郁... 阅读全文
posted @ 2012-07-26 16:06 某某。 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 首先看到这个题号的时候我想起了好公民,韩寒同学和他的不死鸟= =本人二蛋一枚,近日做了些并查集的东西但是一直不太明白怎么才能查节点路径,而且觉得要是迭代的时候加了r[x]的话会出现多加的情况,后来经网上高人指点(觉得还是好人多,虽然自己确实不想做好人了= =)明白了~一下是高人话语~voidmerge(int a,int b){ father[a]=b; place[a]+=number[b]; number[b]+=number[a];}intFind(int a)//检查找和路径压缩{if(father[a]==-1)return a;int tmp=father[a];... 阅读全文
posted @ 2012-07-26 10:26 某某。 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 跟那个排序二叉树的那个静态树一样,不大习惯静态的,但是不静态会tle,94msView Code #include<stdio.h>#include<stdlib.h>#include<string.h>typedef struct node{ int flag; int next[11];}trie;int leap,count;trie tr[100010];new_node(){ int i; count++; tr[count].flag = 0; for(i = 0;i < 10;i++) tr[count].next[i] ... 阅读全文
posted @ 2012-07-26 01:02 某某。 阅读(168) 评论(0) 推荐(0) 编辑