ACM
等候下一场雪
这个作者很懒,什么都没留下…
展开
-
POJ 3617 Best Cow Line
/*贪心算法*/#include using namespace std; #include int main() { int n,i,j; cin>>n; string str1=""; for( i=0;i<n;i++) { char tmp; cin>>tmp; str1+=tmp; } string str2=""; for( i=0;i<n;i++) {原创 2014-10-21 13:46:43 · 308 阅读 · 0 评论 -
poj2386 Lake Counting
/* POJ2386 by wxl at 2014/10/20 考察类容深度优先搜索 */ #include using namespace std; #include char map[101][101]; int n,m; int direction[8][2]={{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{-1,1},{1,-1},{1,1}原创 2014-10-20 21:58:19 · 267 阅读 · 0 评论 -
并查集的基本操作模版
几个模版函数: (1)由一个节点获取它的根节点 //这里的par[u]=get_par(par[u])实际进行了状态压缩,也就是 最后所有节点与父节点之间的深度为1, Int get_par(int u) { If(par[u]!=u) Par[u]=get_par(par[u]); Return par[u]; } (2)查询a,b是否在一个类别下面,也就是原创 2015-11-24 20:01:39 · 265 阅读 · 0 评论 -
LCA离线算法第一波 targin
// testaaaaa.cpp : 定义控制台应用程序的入口点。 // /* targin algorithm */ #include "stdafx.h" #include #include #include using namespace std; #define n 12 int graph[n][n]; int query[n][n]; int fa[n];原创 2015-11-27 21:21:00 · 1221 阅读 · 0 评论 -
SPFA随手写,容易理解的
对应的图是 // spfa.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include using namespace std; int graph[8][8]; #include bool v原创 2016-01-23 20:32:44 · 251 阅读 · 0 评论 -
Prime最小生成树
#include #include #include using namespace std; int graph[8][8]; #include bool visited[8]; int dis[8]; int pre[8]; const int minn=127; void prim(int n) { memset(visited,false,s原创 2016-01-24 12:07:05 · 344 阅读 · 0 评论 -
KMP算法
KMP算法 #include #include #include using namespace std; const int INF=0x7fff; int p[INF]; //ababacb // void findB(string str) { int len=str.length(); string strcopy(len+1,0); strco原创 2016-01-26 14:32:07 · 259 阅读 · 0 评论 -
快速幂和快速矩阵
#include using namespace std; #include const int INF=3; typedef struct node { int m[INF][INF]; }Matrix; Matrix P={2,3,4,4,5,6,4,5,3}; Matrix I={1,0,0,0,1,0,0,0,1}; Matrix multy(Matrix a,原创 2016-01-27 15:22:34 · 253 阅读 · 0 评论