- 博客(28)
- 收藏
- 关注
原创 最小费用最大流
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 267
原创 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 305
原创 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 624
原创 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 267
原创 树的直径
任意点开始搜索,找到当前点能到达最远的点,再对这个点进行一次搜索,得到的即为树的直径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 361
原创 有向图的强连通分量 模板
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 390
原创 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 404
原创 HDU 5294 Tricks Device (最短路+网络流)
题目要求: 至少删除多少条能破坏最短路 最多删除多少条边仍然存在最短路代码来源于:http://blog.csdn.net/u013532224/article/details/46992973#include #include #include #include #include #incl
2015-07-24 19:20:59 268
原创 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 342
原创 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 342
原创 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 288
原创 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 246
原创 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 272
原创 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 276
原创 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 260
原创 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 246
原创 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 358
原创 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 331
原创 最长上升子序列 模板
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 532
原创 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 674
原创 人人都有极客精神
彪悍的翻译的代码,贴上以供仰慕#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 1169
原创 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 289
原创 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 398
原创 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 282
原创 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 257
原创 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 273
原创 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 277
原创 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 359
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人