摘要: 这个题是AC自动机的模版题;#include<stdio.h>#include<stdlib.h>#include<string.h>struct node{ int flag; node *ch[26],*fail; }*q[1000024];node *empty( ){ node *t=( node * )malloc( sizeof( node ) ); memset( t->ch,NULL,sizeof( t->ch ) ); t->flag=0 ; t->fail=NULL ; return t; }void build_ 阅读全文
posted @ 2011-09-18 20:14 wutaoKeen 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 这题就是注意一下当状态为1是就把这两给点合并到一个集合;#include<stdio.h>#include<stdlib.h>struct t{ int x,y,flag,cost; }kru[5024];int set[124];int cmp( const void *a,const void *b ){ return ( ( t * )a )->cost-( ( t * )b )->cost; }int find( int x ){ return x==set[x]?x:set[x]=find( set[x] ); }int kruscal( i... 阅读全文
posted @ 2011-09-18 11:13 wutaoKeen 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 我用G++提交就TLE了,而用C++提交就过了,这题就是一个并查集与克鲁斯卡尔。#include<stdio.h>#include<stdlib.h>struct t{ int x,y,cost; }kru[25024];int set[524];int cmp( const void *a,const void *b ){ return ( ( t * )a )->cost - ( ( t * )b )->cost; }inline int find( int x ){ return set[x]==x?x:set[x]=find( set[x] ); . 阅读全文
posted @ 2011-09-18 11:09 wutaoKeen 阅读(169) 评论(0) 推荐(0) 编辑