自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 hdu 3572 Task Schedule(dinic)

最大流判断满流。这里的满流就是说是否对于题目要求的流量,当前的网络是否流过不溢出,简言之就是最大流>=题目给出的流量。 用dinic的妥妥的T了。原因是对于走过的边重复走了。解决方法是,下一次回到这个节点时走的就是剩下没走过的边。然后get了一个新技能,当前弧的概念,也简言之就是走过的边不再走,但是实现的话,首先确定head不能变,就拿一个临时数组cur来充当head,而cur的变化正好解决了走

2014-12-29 22:07:23 519

原创 hdu 4240 Route Redundancy(dinic)

题意很别扭的的一道题,先是求最大流,再求所有可行流中的流量最大的那个流(因为该流的流量取决于该流上流量最小的那条边,正好是题意要求的),然后求其比值即可 而dinic在dfs到汇点的时候正好也可以求出上述的流大小 #include #include #include #include #include using namespace std; const int N = 100005;

2014-12-28 22:07:13 497

原创 hdu 3549 Flow Problem(最大流)

最大流模板题 #include #include #include #include #include using namespace std; #define tt printf("ewgaergasergs\n"); const int N = 10005; struct node{ int nxt, w, v; }e[N]; int head[100], re[

2014-12-27 16:33:22 494

原创 poj 1273 & hdu 1532 Drainage Ditches(最大流 )EK,dinic模板

第一发网络流纪念下~~~ 因为这里e和v都差不多,所以EK和dinic跑出来的时间差不多。纠结的是如何把邻接矩阵换成邻接表的.. EK写法: //沿此路径添加反向边,同时修改路径上每条边的容量#include #include #include #include #include using namespace std; typedef __int64 ll; const int

2014-12-25 15:41:43 606

原创 Codeforces Round #284 (Div. 2) A B C

A - Watching a movie :看电影,每个镜头从li ~ ri 且保证 li+1 > ri。每次能跳过X分钟,问从第一分钟开始看起看完所有时间需要多少时间。 注意第i分钟看完电影放到第i+1分钟就好了。 #include #include #include using namespace std; int main() { int n, x; int l, r

2014-12-25 15:07:04 501

原创 Codeforces Round #283 (Div. 2) A B C

A - Minimum Difficulty 给出n个数字,删去一个数之后的求剩下的n-1个数之间的差最大值最小的那个值。 #include #include #include using namespace std; const int N = 105; int a[N], c[N], z[N]; int main() { int n; while(~sc

2014-12-22 15:50:17 537

原创 Codeforces Round #282 (Div. 2) A - Digital Counter B - Modular Equations C - Treasure

A - Digital Counter: #include int a[10] = { 2, 7, 2, 3, 3, 4, 2, 5, 1, 2 }; int main() { int x; while(~scanf("%d", &x)) { printf("%d\n", a[x%10] * a[x/10]); } return

2014-12-18 17:11:54 450

原创 hdu 2586 How far away ?(LCA离线)

记录下所有的提问,在建tarjan建一颗深搜树的时候询问。奇怪这道题的edge开4W会RE,,于是任性的开了40W妥妥过. #include #include #include #include using namespace std; const int N = 400005; const int M = 205; struct node{ int v, w, nxt; }e[

2014-12-17 20:02:43 403

原创 poj 1753 Flip Game (dfs)

裸爆搜。但是要注意搜索方法.. 可参考http://blog.csdn.net/lyy289065406/article/details/6642595 #include #include #include #include using namespace std; int a[10][10]; char c[10][10]; int tt; bool flag; void flip(i

2014-12-16 20:09:30 437

原创 hdu 3861 The King’s Problem

The King’s Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1792    Accepted Submission(s): 652 Problem Description In the Kingd

2014-12-12 21:52:15 495

原创 hdu 1827 Summer Holiday(tarjan)

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1827 求联通块入度为0的数量及传递到整个图的最小花费。算是tarjan的模板题了 #include #include #include #include #include using namespace std; const int N = 1005; const int inf = 1 <

2014-12-12 17:17:35 436

原创 hdu 3268 Columbus’s bargain (spfa)

题意:哥伦布找土著换东西,共有四个方案:1 拿钱换等价的东西,(无用条件)2 拿一颗玻璃球代替一枚金币,然后换等价的东西。3 等价的东西可以互换(容易落下这个条件)。4 用东西+钱 换另一样东西(不是补差价),比如 price[1] = 5, price [2] = 20, 但是可以用 thing1 + 5换得thing2 = =。 从上面第四点很明显看出是一个潜在的松弛过程。那么建图的时候就建

2014-12-10 21:45:02 601

转载 各种各样的输入输出挂 mmdns~

原链接:点击打开链接 先上C的: 适用于正int的. int read() { char ch=' '; int ans=0; while(ch'9') ch=getchar(); while(ch='0') { ans=ans*10+ch-'0'; ch=getchar(); } r

2014-12-10 18:46:54 658

原创 hdu 3605 Escape 多重匹配模板 (Hungary ) | 最大流

N个人M个星球,每个人都有适合居住的星球,每个星球有最大的容纳人数。求是否行星能满足住人。 相比二分图求最大匹配,变化在link数组的应用,及对行星人数限制这个条件寻找增广轨,而这里的增广轨即 ”原先已经找好居住行星的人需要找新的行星“ 这一过程。跑一次Hungary即可。注意这里要用c++否则会T。神奇的输入挂可减很多时间 #include #include #include using

2014-12-10 18:41:05 570

原创 hdu 2145 zz's Mysterious Present

题意:N个城市M个人K条单向边,每个人的速度不同,且在一些城市中。求到达终点时用时最少的人的编号。当用时相同时速度大的优先,速度也相同时编号大优先。 建反向边以终点为源点跑一次spfa即可。因为求的是时间,开始是把时间放在spfa的松弛里面更新的,,但其实T = S / V,求出S(dis)也就求出了时间,我的蠢愚。。 #include #include #include #include

2014-12-09 21:42:20 508

原创 hdu 3873 Invade the Mars(heap + dij变形)

思路:题目意思很简单,就是说如果没有攻占保护x的城市,就不能攻占,我们可以用pro[x]记录保护x的所有城市被攻占的最早时间,那么能到x的最短时间为pro[x]和到达x的最短路中的较大者 .dij入队过程中只把In[x](没有被包含的城市)入队 对于出队的x,它的最短时间已经确定,表示已经被占领,它所保护的城市的保护度减 1,一旦某个被保护的城市的保护度为零且已经到底(未占领,d[x]!=inf

2014-12-08 22:04:47 722

原创 hdu 3832 Earth Hour(斯坦纳树)

题意:校园平面内有一些灯,在(X,Y)的点能照亮半径为R的圆的面积。两个圆有一部分重合或者边相切认为这两个圆相连。问删去一些圆是否圆1 2 3是否能直接或间接的联通。若可以则输出最大能删去的圆的数目,不行则输出-1. 原来这种神奇的东西叫做斯坦纳树。。当然最后是最短路写出来的,分别以1 2 3为源点spfa。然后求得D1【】, D2【】, D3【】。则ans = n-min(d1【】 + d2【

2014-12-08 19:25:53 585

原创 hdu 3631 Shortest Path (floyd)

n个点从0 , 1, 2 ,3.....n-1,这些点只有被标记过之后才能走,求给出的两点之间的最短路。 Floyd的思想拿来插点。很容易想到两种更新两点之间距离的大概思路: 1:给出的两点X,Y,遍历所有点看是否能够松弛,即dis【X】【Y】 = MIN(dis【x】【i】 + dis【i】【Y】)。 2:对每次给出的新的标记的点Z,以其为松弛点遍历整张图里的点对之间距离,即dis【i】【

2014-12-08 18:10:18 421

原创 hdu 1054 Strategic Game 最小点覆盖

建双向边,然后最大匹配/2。另外邻接矩阵会T.. #include #include #include using namespace std; const int N = 1505; struct node{ int to, nxt; }e[N*N]; int head[N]; int cnt; int n; int link[N], vis[N]; void add( int u,

2014-12-06 22:36:50 453

原创 hdu 5138 CET-6 test 5139 Formula

5138:暴力比打表快= = #include #include #include using namespace std; const int N = 100555; vector v[N]; int a[5] = { 1, 2, 4, 7, 15 }; void init() { for( int i = 1; i <= 100005; i++ ) {

2014-12-06 22:03:56 612

原创 hdu 1839 Delay Constrained Maximum Capacity Path 二分+ spfa

有N个点,点1为珍贵矿物的采矿区, 点N为加工厂,有M条双向连通的边连接这些点。走每条边的运输容量为C,运送时间为D。选择一条从1到N的路径运输, 这条路径的运输总时间要在T之内,在这个前提之下,要让这条路径的运输容量尽可能地大。一条路径的运输容量取决与这条路径中的运输容量最小的那条边。 带限制的最短路--- 由于每条路都是有一定容量的,相对来说,容量越大那么满足的边就越少。就可以二分容量

2014-12-06 15:19:58 424

原创 hdu 1599 find the mincost route floyd求最小环

最小环见 点击打开链接 #include #include #include using namespace std; const int inf = 1 << 28; const int N = 105; int a[N][N]; int dis[N][N]; int n, m; int ans; void init() { for( int i = 1; i <= n; i

2014-12-05 21:19:20 351

原创 hdu 3986 Harry Potter and the Final Battle

和hdu 的1595很像,但是多的是出现重边,即无法用邻接矩阵这种方式存图。而在邻接表记录边是,每次删边的操作,其实就是在松弛过程中遍历到需要删除的边时,跳过即可。那么就可以加一个数组记录边,然后使用时判断是不是要删边就好了。 #include #include #include #include using namespace std; #define N 1005 const int i

2014-12-05 20:10:23 477

原创 hdu 1595 find the longest of the shortest (spfa)

记录最短路上的路径依次枚举删掉,看看剩下的最短路最大值是多少。 #include #include #include #include using namespace std; #define N 1005 const int inf = 1 << 28; struct node{ int to, nxt, w; }e[N*N]; int dis[N], vis[N]; int

2014-12-04 20:31:24 472

原创 Codeforces Round #280 (Div. 2)A B C

A - Vanya and Cubes: #include #include #include using namespace std; typedef __int64 ll; const int N = 10005; ll a[N]; int main() { a[0] = 0; for( ll i = 1; i <= 10000; i++ ) {

2014-12-04 16:54:40 452

原创 NYOJ 847 S + T

预处理出右边Aj,然后扫一遍即可 NYOJ要用 long long... #include #include #include using namespace std; const int N = 100000 + 10; typedef __int64 ll; struct node{ ll val, pos; }p[N]; ll a[N]; int main() { i

2014-12-03 22:10:25 457

原创 hdu 2923 Einbahnstrasse

#include #include #include #include #include #include #include using namespace std; const int N = 105; const int inf = 1 << 28; struct node{ int nxt, to, w; }e[N*N]; map mp; string str[N*10];

2014-12-03 20:38:20 476

原创 hdu 1546 Idiomatic Phrases Game (spfa)

读取的字符串一定要开的大一点啊不然就是无尽的RE #include #include #include #include #include using namespace std; const int N = 1005; const int inf = 1 << 28; struct pp{ int st, ed, val; }p[N]; struct node{ int

2014-12-03 17:10:19 560

原创 hdu 1317 XYZZY spfa判断负环

#include #include #include using namespace std; const int N = 105; const int inf = 1 << 28; int a[N][N], c[N]; int dis[N]; int cost[N]; int vis[N]; int n; bool spfa() { memset(dis, 0, sizeof(dis

2014-12-02 21:48:50 515

原创 hdu 1217 Arbitrage (Floyd)

#include #include #include #include #include #include #include using namespace std; const int N = 50; map mp; int cnt; int n, m; double a[N][N]; int main() { int _ = 1; cin.sync_with_stdio( 0 );

2014-12-01 21:03:32 424

原创 hdu 2066 一个人的旅行 spfa + 建超级源点汇点

#include #include #include #include using namespace std; const int N = 10005; const int inf = 1 << 27; struct node{ int to, nxt, w; }e[N*2]; int dis[N]; int head[N]; int T, S, D; int maxx; int tot

2014-12-01 19:41:25 511

原创 hdu 3790 最短路径问题

使用邻接表的过了,邻接矩阵的跪了囧rz。改不出来望路过的看出哪里错的人赐教== 邻接表: #include #include #include #include using namespace std; const int M = 100005; const int N = 1004; const int inf = 0x3f3f3f3f; struct node{ int nx

2014-12-01 18:55:54 472

空空如也

空空如也

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

TA关注的人

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