自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(152)
  • 收藏
  • 关注

原创 最小费用最大流

const int MAXN = 10000;const int MAXM = 100000;const int INF = 0x3f3f3f3f;struct Edge{ int to, next, cap, flow, cost;} edge[MAXM];int head[MAXN], tol;int pre[MAXN]; //储存前驱顶点int dis[MAXN];

2015-07-28 11:12:55 274

原创 ZOJ 3888 Twelves Monkeys

线段树应用 查询区间次小值 #include #include #include #include #include #include #include #include #include #include #define clc(arr, val) memset(arr, val, sizeof(arr))#define FOR(i,a,b) for(int i

2015-07-28 09:02:19 321

原创 ZOJ 3885 The Exchange of Items

最小费用最大流~。。 建图需要理解理解,其他都是模板#include #include #include #include #include #include #include #include #include #include using namespace std;typedef long long ll;const int MAXN = 10000;c

2015-07-28 09:02:02 635

原创 HDU 1754 I Hate It (线段树)

线段树的基础应用~~ 补发#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype"#include "sstream"#include "cstdlib"#inclu

2015-07-25 11:04:01 279

原创 树的直径

任意点开始搜索,找到当前点能到达最远的点,再对这个点进行一次搜索,得到的即为树的直径void bfs(int s){ queueq; memset ( vis, 0, sizeof(vis) ); qu.push(s); dist[s] = 0; vis[s] = 1; maxs = 0; while ( !qu.empty()

2015-07-25 10:47:26 374

原创 有向图的强连通分量 模板

const int MAXN = 10010; //点数const int MAXM = 100100; //边数struct edge{ int to,next;} edge[MAXM];int head[MAXN],tot;int Low[MAXN],DFN[MAXN],Stack[MAXN];int Belong[MAXN]; //标记当前点属于第几个强连通分量

2015-07-25 10:29:26 404

原创 HDU 1269 迷宫城堡 (有向图的强连通分量)

判断是否为强连通图,跑一遍模板,强连通分量的个数为1,即为强连通图#include #include #include #include #include #include using namespace std;const int MAXN = 10010; //点数const int MAXM = 100100; //边数struct edge{

2015-07-25 10:22:46 414

原创 HDU 5294 Tricks Device (最短路+网络流)

题目要求:                 至少删除多少条能破坏最短路                 最多删除多少条边仍然存在最短路代码来源于:http://blog.csdn.net/u013532224/article/details/46992973#include #include #include #include #include #incl

2015-07-24 19:20:59 282

原创 HDU 5289 Assignment (RMQ+二分)

求任意区间满足R-L#include #include #include #include #include #include using namespace std;typedef long long LL;const int inf = 0x3f3f3f3f;const double oo = 10e9;const double eps = 10e-9;const i

2015-07-22 13:23:24 352

原创 RMQ 一维模板

void intRMQ(int n,int b[]){ mm[0]=-1; for(int i=1; i<=n; ++i) { mm[i]=((i&(i-1))==0)?mm[i-1]+1:mm[i-1]; //计算长度 n为2的倍数 n&n-1==0 dp[i][0]=b[i]; //初值 }

2015-07-22 10:56:55 358

原创 HDU 4604 Deque

!!流弊的方法#include #include #include #include #include using namespace std;const int inf = 0x3f3f3f3f;const int M = 100011;int n;int a[M];vectorv;inline void gao(int now){ if (v.empty

2015-07-21 22:21:11 304

原创 POJ 3304 Segment

直线与线段相交,枚举直线的端点 用叉积判断是否有交点#include "cstring"#include "iostream"#include "algorithm"#include "cstdio"#include "queue"#include "set"#include "cmath"using namespace std;typedef long long LL;co

2015-07-20 21:00:36 256

原创 POJ 1113 Wall

求围墙的长度 就是里面凸包的周长+半径为L的圆周长#include "cstring"#include "iostream"#include "algorithm"#include "cstdio"#include "queue"#include "set"#include "cmath"using namespace std;typedef long long LL;con

2015-07-20 19:18:46 298

原创 POJ 2420 A Star not a Tree?

求多边形的费马点,,爬山算法#include "cstring"#include "iostream"#include "algorithm"#include "cstdio"#include "queue"#include "set"#include "cmath"using namespace std;typedef long long LL;const int M=51

2015-07-20 18:47:51 285

原创 HDU 3998 Sequence

求最长上升子序列的长度以及个数,由于数据水,可以直接找  正解是DP+网络流#include "cstring"#include "iostream"#include "algorithm"#include "cstdio"#include "queue"#include "set"using namespace std;typedef long long LL;const i

2015-07-19 21:13:46 264

原创 POJ 1149 PIGS

最大流,给定M个猪圈 N个商人 每个商人可以选择特定的猪圈买猪 当一个商人同时可以选择多个猪圈时,此时猪圈可以互通,就是此时两猪圈的流量上限为INF#include "cstring"#include "iostream"#include "cstdio"#include "queue"using namespace std;typedef long long LL;c

2015-07-19 18:59:35 257

原创 ZOJ 3230 Solving the Problems

贪心思想,优先队列处理,用set应该也可以。#include "cstring"#include "iostream"#include "algorithm"#include "cstdio"#include "queue"#include "set"using namespace std;typedef long long LL;const int M=100050;con

2015-07-19 18:57:46 370

原创 LightOJ 1153 Internet Bandwidth

On the Internet, machines (nodes) are richly interconnected, and many paths may exist between a given pair of nodes. The total message-carrying capacity (bandwidth) between two given nodes is the maxi

2015-07-19 18:53:56 341

原创 最长上升子序列 模板

int a[M],b[M];int search(int num,int low,int high){ int mid; while(low<=high) { mid=(low+high)/2; if(num>=b[mid]) low=mid+1; else high=mid

2015-07-19 18:37:09 560

原创 HDU 5285 wyh2000 and pupil

用染色法判断一下就好,不认识的人不同的颜色即不同分组,人数最多的一组在前#include#include#includeusing namespace std;typedef long long LL;int edgenum;int n,m;int flag;int color[100010];int colornum[2];int head[100010];int v

2015-07-19 08:46:41 696

原创 人人都有极客精神

彪悍的翻译的代码,贴上以供仰慕#include using namespace std;typedef long long LL;int a[]={6, 2, 5, 5, 4, 5, 6, 3, 7, 6};int da[2][12]={{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 29,

2015-07-18 17:14:57 1207

原创 HDU 1281 棋盘游戏

将行与列构成二分图  重要点就是每次去除一个点,然后再找最大匹配 如果小于原来的最大匹配 说明该点为重要点#include#include#include#include#includeusing namespace std;#define mod 100000007typedef long long LL;const int M = 310;int mp[105][105

2015-07-12 10:16:27 304

原创 Base64_解码 C

int change(char ch) //解码表转换 转成2进制 由于小于64 所以最多6位二进制{ if( ch>='A'&&ch<='Z' ) return ch-'A'; if( ch>='a'&&ch<='z' ) return ch-'a'+26; if( ch>='0'&&ch<='9' ) ret

2015-07-09 10:04:15 405

原创 HDU 2896 病毒侵袭 (AC自动机)

记录串的id 用end数组来记录  ASCII可见字符从32~128#include #include #include #include #include using namespace std;struct Trie{ int next[205*500][128],fail[205*500],end[205*500]; int root,L; int

2015-07-08 10:32:57 291

原创 HDU 2222 Keywords Search

经典自动模板机#include #include #include #include #include using namespace std;struct Trie{ int next[500010][26],fail[500010],end[500010]; int root,L; int newnode() //开辟空间 {

2015-07-08 09:40:56 266

原创 Trie树

在Trie树中主要有3个操作,插入、查找和删除。一般情况下Trie树中很少存在删除单独某个结点的情况,因此只考虑删除整棵树。1.插入  假设存在字符串str,Trie树的根结点为root。i=0,p=root。  1)取str[i],判断p->next[str[i]-97]是否为空,若为空,则建立结点temp,并将p->next[str[i]-97]指向temp,然后p指向

2015-07-07 09:40:04 279

原创 HDU 2444 The Accomodation of Students

典型的二分图匹配,首先要判断是否为二分图 用染色法,然后就是匈牙利算法。#include#include#include#includeusing namespace std;typedef long long LL;const int M = 210;struct node{ int from,to,next;} edge[210*210];int

2015-07-06 15:49:57 292

原创 HDU 3068 最长回文

Manacher算法使用,O(n)回文字串算法#include "cstring"#include "iostream"#include "cstdio"using namespace std;typedef long long LL;const int M=55;const int maxn=2147483648;//string s;char s[110000*2+10]

2015-07-05 10:52:49 370

原创 ZOJ 3870 Team Formation(异或运算)

题意:给出n个数,其中两个数的异或能大于他们本身。。好气啊aaa,思路都对了,可惜没弄出来,,不难发现换成二进制后,某个数的最高位在其他数对应的数位为0的话,肯定比这两个数要大。。只要先储存下所有数的位数QAQ~~,然后再循环判断后面位数为0的情况。。#include "string"#include "iostream"#include "cstdio"#include "c

2015-04-26 10:14:52 356

原创 The 12th Zhejiang Provincial Collegiate Programming Contest

水题6题。。。。不想多说了,B题也是爆炸爆炸,最后还是没想出来。A:水#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype"#include "ss

2015-04-25 19:08:55 253

原创 最短路模板合集~(Dij+Floyd+Spfa)

自己整理的最短路模板,,对于最短路问题主要就是难在构图方面~~ //Dijstravoid Dijstra(){ int i,j; for(i=0; i<n; ++i) { dis[i]=INF; vis[i]=0; } dis[1]=0; int v; for(i=1

2015-04-20 11:52:29 1706

原创 POJ 1511 Invitation Cards (spfa)

求到某点的来回最短距离,数据太大,要用spfa邻接矩阵存储,将两点互换再求一次最短路,所有距离和即为所求#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype

2015-04-19 10:13:41 326

原创 HDU 5206 Four Inages Strategy

#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype"#include "sstream"#include "cstdlib"#include "c

2015-04-18 21:48:58 676 1

转载 容斥原理

来源:http://www.cppblog.com/vici/archive/2011/09/05/155103.html 前言:这篇文章发表于http://e-maxx.ru/algo/inclusion_exclusion_principle,原文是俄语的。由于文章确实很实用,而且鉴于国内俄文资料翻译的匮乏,我下决心将其翻译之。由于俄语对我来说如同乱码,而用Google

2015-04-18 21:07:38 473

原创 ZOJ 2836 Number Puzzle (容斥原理)

理解的好辛苦啊,,ym final爷,几分钟就能A出来!!  二进制真是好东西啊 #include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype"#inc

2015-04-18 21:05:39 367

原创 POJ 1860 Currency Exchange(spfa)

最短路水题,,如果货币在转换中能涨价就不用再判断了。。#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype"#include "sstream"#i

2015-04-18 10:23:15 327

转载 C++ Set常用用法

set集合容器:实现了红黑树的平衡二叉检索树的数据结构,插入元素时,它会自动调整二叉树的排列,把元素放到适当的位置,以保证每个子树根节点键值大于左子树所有节点的键值,小于右子树所有节点的键值;另外,还得保证根节点左子树的高度与右子树高度相等。平衡二叉检索树使用中序遍历算法,检索效率高于vector、deque和list等容器,另外使用中序遍历可将键值按照从小到大遍历出来。构造set集合主要

2015-04-18 08:59:43 390

原创 Dijstra与prim

Dijstra模板:const int MAXSIZE=100;const int INF=1000000;//除对角线外最初都要初始化为无穷int dist[MAXSIZE];void Dijkstra(int cost[][MAXSIZE],int n,int v)//求v到各个顶点的最短路径{ int i,j,k,min,set[MAXSIZE]; memset(

2015-04-16 21:21:58 338

原创 ZOJ 3861 Valid Pattern Lock

全排列之后筛选。。#include "string"#include "iostream"#include "cstdio"#include "cmath"#include "set"#include "queue"#include "vector"#include "cctype"#include "sstream"#include "cstdlib"

2015-04-13 15:10:44 289

原创 ZOJ 3865 Superbot(BFS水题)

比赛的时候题意理解错了,不想多说什么了。。水题一道,,给你四个按钮,每次你可以选择不动,左右移动按钮,按钮每P秒右移一次,,水啊#include "stack"#include "cstdio"#include "iostream"#include "cmath"#include "set"#include "sstream"#include "cctype"#

2015-04-13 14:53:10 352

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除