- 博客(8)
- 资源 (6)
- 收藏
- 关注
转载 2011年第36届大连赛区现场赛Board
First to solve problem Solved problem Attempted problem S# School Rk Team Slv. Time A 2/18 B 15/89 C 20/189
2011-09-25 20:02:23
4750
1
原创 字符串匹配
<br /><br />kmp算法<br />设有主串s和子串t,子串t定位是指在主串s中找到一个与子串t相等的子串。通常把主串s称为目标串,把子串t称为模式串,因此定位也称作模式匹配。模式匹配成功是指在目标串s中找到一个模式串t。<br />传统的字符串模式匹配算法(也就是BF算法)就是对于主串和模式串双双自左向右,一个一个字符比较,如果不匹配,主串和模式串的位置指针都要回溯。这样的算法时间复杂度为O(n*m),其中n和m分别为串s和串t的长度。<br />KMP 算法是由Knuth,Morris和Pra
2011-05-18 20:47:00
304
原创 八皇后夹墙版
<br />view plaincopy to clipboardprint?/* 来自网络。很精典。dfs的精典利用。什么时候我也能想出这样的算法呀,努力!!!!! */ #include <stdio.h> bool canput(char map[5][5], int y, int x){ //判断能不能放塔 if(map[y][x] != '.')return 0; //以经放塔或者为墙。不能放塔 int i; for(i = y - 1; i >= 0; i--)
2011-04-23 19:56:00
276
原创 AOV 拓扑排序
<br />#include<iostream>using namespace std;struct arcnode { int adjv; arcnode *arcnext; arcnode(int v=0,arcnode *next=NULL) {adjv=v;arcnext=next;}};struct Vnode { int innum; int vist; char v; arcnode *firstarc;}vn
2011-04-22 11:31:00
1075
原创 遍历图 DFS
<br />#include<stdio.h> #include<string>int a[50][50]={0};int vist[50]={0};int cnt=0;void dfs( int v,int m){ int i; vist[v]=1; cnt++; for(i=0;i<m;i++) { if(a[v][i]==1) { if(vist[i]==0)
2011-04-22 11:18:00
326
原创 最小生成树 Kruscal
<br />#include<iostream>#include<algorithm>#include<cmath>using namespace std;struct node { int x; int y; int w;}v[100];int set[100];bool cmp(node a,node b){ return a.w<b.w;}int find(int x){ if(set[x]!=x) { return fin
2011-04-22 11:00:00
315
原创 最小生成树 Prim
<br />#include<iostream>using namespace std;int main(){ int n,m,b,i,j,x,y,min,w,k,vnum; cin>>n; while(n--) { int a[52][52]={0},cost[100]={0},sum=0; cin>>m>>b; if(b==0) { for(i=1;i<=m;i
2011-04-22 10:47:00
215
原创 遍历二叉树
遍历二叉树Acceteped : 500 Submit : 794 Time Limit : 1000 MS Memory Limit : 65536 KB Description<br />根据输入重构一个二叉树,输出按不同顺序遍历的节点序列<br /><br />数据输入:<br />第一行是一个整数N(1<=N<=20),表示有多少个测试例子,以下每行是一个测试例子。每个测试例子第一个是一个整数M,表示输出的遍历顺序,其中M=0,表示前序;M=1,表示中序;M=2,表示后序。然后是一个字符序列,字符
2011-04-22 10:31:00
252
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人