
图论
MQLYES
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
最小生成树 prim 算法 与kruskal 算法
prim: int prim(){ for(int i=1; i { mincost[i]=inf;//mincost[i]为到当前生成树的最小距离 used[v]=false; } mincost[1]=0; int res=0; while(true) {原创 2015-02-26 19:58:27 · 442 阅读 · 0 评论 -
UVA 11324 scc缩点+树上最长路
#includeusing namespace std;const int maxn = 1010;vectorg[maxn];vectorm[maxn];int node[maxn];int pre[maxn],lowlink[maxn],sccno[maxn],dfs_clock,scc_cnt;int dp[maxn];stacks;void dfs(int u){原创 2016-05-23 21:21:50 · 535 阅读 · 0 评论 -
HDU 5727 Necklace 2016多校第二场
题意: n个阴性球 n个阳性求,要求组成一个阴阳球交替的项链。 有些阴性球号和阳性球号在一块,阳性就会减弱,问怎样安排使得减弱的阳性球号尽可能少。 思路: 刚开始想错了两个地方,想的是只要将不影响的阴性球和阳性球建边,然后用n - 二分最大匹配。显然是错的。 因为要匹配的是不相互影响的位置。所以 应该根据位置相互不相互影响建立边。这样就要枚举一种球的位置。 O((n-1)!) 然后再根据求原创 2016-07-22 17:47:33 · 491 阅读 · 0 评论 -
poj 1236 Network of Schools
题目大意: 给出一个有向图,问1: 至少从几个点出发,可以遍历所有的点。 2: 至少添几条边可以可以是图强连通。 将图中的强连通分量缩点后,成一个 DAG(有向无环图); 图中 入度为0的点是无法通过其他点到达的,且图中从所有入度为0的点出发定能到达图中所有的点,因为其他点入度不为0。所以第一问答案就是入度为0点的个数。 2: 及入度为0点a,出度为0点b . 强连通图是由若干个环组成的。原创 2016-07-16 19:37:02 · 333 阅读 · 0 评论 -
codeforces 687A
题意: n个点m个边 ,要求将点分为两组,每组含每条边的一个点。 单独的点可以分到任何一组。 思路: 奇偶染色。 #includeusing namespace std;const int maxn = 100010;int col[maxn];vectorv[maxn];bool dfs( int u ,int color ){ col[u] = color;原创 2016-07-06 18:07:15 · 620 阅读 · 0 评论 -
hdu 5361 2015多校联赛第六场 In Touch
题意: 每个点可以到左右两个范围内的点并花费为Ci, 问1 到 所有点的最短距离。 用普通的优先队列最短路不行,复杂度高,且边较多。、这里要用dijstra的一个性质,那就是在未使用过的点中挑选出离S最近的 X,之后这个X不会再更新,如果用优先队列来写的话就表现为从队列里出来的点不会再被更新我们设到达V点最近的距离为dis[v], 如果我们把原创 2016-07-09 16:31:05 · 450 阅读 · 0 评论 -
2016 湘潭邀请赛 c 题 Hamiltonian Path
现场赛的一道题 In ICPCCamp, there are n cities and m directed roads between cities. The i-th road going from the ai-th city to the bi-th city is ci kilometers long. For each pair of cities (u,v), ther...原创 2016-06-07 20:35:43 · 1518 阅读 · 0 评论 -
2015 ICPC 沈阳站M题
M - MeetingTime Limit:6000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 5521Appoint description: System Crawler (2016-04-18)DescriptionB...原创 2016-04-21 21:35:28 · 1925 阅读 · 0 评论 -
hdu 5823 2016多校联赛8
题意:原创 2016-08-13 11:05:02 · 408 阅读 · 0 评论 -
hihocoder 1379 Emulator
时间限制:5000ms单点时限:1000ms内存限制:256MB描述有一个n个点的无向正权图G,这个图是连通的,小Y知道这些点两两之间的最短路的长度。小J想要构造一个新的无向正权图G',使得新图中两两之间的最短路的长度与原图一样,并且边数最少。输入第一行一个整数n,表示点的个数。接下来n行,每行n个整数。第i行第j个整数表示i点到j点的在原创 2016-10-12 14:06:09 · 443 阅读 · 0 评论 -
UVA 10480
题意:网络流:求最小割,并输出割边最后一次不能增广后的残图,割边定是容量==流量的点即残图残量为0 的边,将图中的点分为 两部分,一部分为 原点能到达的点,量一部分为不能到达的点如果 u 可以到达而 v 不可到达,且 u --v 之间本来就有一条边则该边为割边#include#include#include#includeusing namesp原创 2016-04-07 20:08:26 · 672 阅读 · 0 评论 -
codeforces 653D
题意:有n个点m条有向边带权图,权值代表该路径允许通过的最大物品重量。现在你要用x个小熊同时从点1到点n运物品,要求每个小熊运的物品重量相等。问所有小熊可以运送的最大重量和思路: 二分所求的答案k = key/x, 则将每条边的容量/ k 即是每条边所通过的小熊个数 ,最后看能通过的最多小熊个数与小熊总数比较 二分次数100 即可#includeusing原创 2016-03-23 21:10:13 · 563 阅读 · 0 评论 -
poj 2195
#include#include#include#include#includeusing namespace std;const int INF = 1000;char a[101][101];typedef pairP ;struct edge{ int to ,cap,cost,rev;};int V;const int maxn = 1000;vecto原创 2016-04-04 13:02:11 · 353 阅读 · 0 评论 -
生成树计数 nyoj 127
给出n个点,问有多少种方法可以用n-1条边生成树,ans=pow(n,n-2);原创 2015-05-22 14:45:22 · 461 阅读 · 0 评论 -
HDU 1083 二分匹配
#includeusing namespace std;vectorv[305];int vis[305];int link[305];bool dfs(int u){ for(int i=0; i<v[u].size(); i++) { if(!vis[v[u][i]]) { vis[v[u][i]]=1; if(!link[v[u][i]] || dfs(link[v[u][i]])) { l原创 2015-08-26 17:05:22 · 428 阅读 · 0 评论 -
二分匹配 月老的难题
#includeusing namespace std;#define MAX 1010int used[MAX];int march[MAX];vectorg[MAX];bool dfs(int u){ for(int i=0; i<g[u].size(); i++) { if(!used[g[u][i]]) { used[g[u][i]]=true; if(march[g[u][i]]==-1原创 2015-07-03 16:10:15 · 511 阅读 · 0 评论 -
NYOJ 237 游戏高手的烦恼 最小点集覆盖 = 二分图最大匹配
游戏高手的烦恼时间限制:1000 ms | 内存限制:65535 KB难度:5描述有一位传说级游戏高手,在闲暇时间里玩起了一个小游戏,游戏中,一个n*n的方块形区域里有许多敌人,玩家可以使用炸弹炸掉某一行或者某一列的所有敌人。他是种玩什么游戏都想玩得很优秀的人,所以,他决定,使用尽可能少的炸弹炸掉所有的敌人。现在给你一个游戏的状态,请你帮助他判断原创 2015-08-29 16:01:48 · 550 阅读 · 0 评论 -
hdu 5423 统计树每一层的节点树 dfs
roblem DescriptionAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:For a tree T, let F(T,i) be原创 2015-08-30 15:57:06 · 518 阅读 · 0 评论 -
NYOJ 单词拼接
单词拼接时间限制:3000 ms | 内存限制:65535 KB难度:5描述给你一些单词,请你判断能否把它们首尾串起来串成一串。前一个单词的结尾应该与下一个单词的道字母相同。如alohadogarachnidgophertigerrat 可以拼接成:aloha.ara原创 2015-11-05 14:04:01 · 651 阅读 · 0 评论 -
bnu Inspector's Dilemma
证明: 一个联通图 度数为奇数的点的个数只可能是小于2 ,也就是说不可能出现度数是奇数的点的个数为奇数将一个联通图构成欧拉道路,需 添(k-2)/2条边,k 为度数为奇数的点的个数 统计出有x个联通块,需加 x - 1 条边//}#includeusing namespace std;const int maxn = 1010;int flag[maxn];int v原创 2015-11-08 18:36:57 · 435 阅读 · 0 评论 -
nyist 彩色棒
#includeusing namespace std;const int maxn =2500005 ;int m = 1;int f[maxn];struct node{ node * next[26]; int order;} ;int du[maxn];int find(int x){ return x==f[x]?x:f[x] = find(f原创 2015-10-28 14:10:58 · 386 阅读 · 0 评论 -
hdu 5606
#include#include#includeusing namespace std;const int maxn = 1e5+10;int f[maxn];int flag[maxn];int find(int x){ return x==f[x]?x:f[x] = find(f[x]);}void unit(int x,int y){ int boss原创 2016-01-03 10:44:02 · 813 阅读 · 0 评论 -
hdu 1285
三位一体”全攻略! 招聘——巴卡斯科技(杭州)、英雄互娱(杭州)确定比赛名次Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19496 Accepted Submission(s): 7807原创 2016-03-09 17:40:21 · 435 阅读 · 0 评论 -
HDU3339:In Action(Dijkstra+01背包)
题意: 有 n个发电站 编号 1到n ,每个发电站有一个pow 值, m条边 每条边有一个cost 值, 要求 选出一些点,使得这些点的pow值>sum(pow)/2 并且 从0号到每个点的最短距离和最小。 最短路+01背包, 0号到每个点的最短距离作为价值 , pow作为花费。#includeusing namespace std;struct node{原创 2016-11-08 16:56:49 · 729 阅读 · 0 评论