ACM图论
桑榆207
在最终的结果到来之前,任何肯定会赢之类的话都是虚无缥缈的。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ 3256 Cow Picnic(深搜+vector||深搜剪枝+邻接链表)
The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ 100) cows is grazing in one of N (1 ≤ N ≤ 1,000) pastures, conveniently numbered 1...N. The pastures are connected by M (1 ≤ M ≤ 10,00...原创 2018-08-15 09:38:31 · 217 阅读 · 0 评论 -
CF-- Mother of Dragons--最大团
E. Mother of Dragons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There arencastles in the Lannister's Kingdom and some wall...原创 2019-08-12 22:06:16 · 230 阅读 · 0 评论 -
百度之星初赛一--Mindis--思维建图
Mindis Accepts: 127 Submissions: 791 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Problem Description 平面上有 nnn 个矩形,矩形的边平行于坐标轴,现在度度熊需要操控一名角色从 AAA 点走到 BBB 点。 ...原创 2019-08-19 09:07:37 · 324 阅读 · 0 评论 -
CF图论一-- Ice Skating--DFS||BFS||并查集
、、 C. Ice Skating time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bajtek is learning to skate on ice. He's a beginner, so his on...原创 2019-07-21 21:14:29 · 236 阅读 · 0 评论 -
HDU1530 Maximum Clique 最大团(最大完全子图)
http://acm.hdu.edu.cn/showproblem.php?pid=1530 Problem Description Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all vertex pairs v1, v2 in v, there exists an edge (v1, ...原创 2019-01-23 17:11:14 · 332 阅读 · 0 评论 -
六度空间Floyed最短路变形
https://vjudge.net/contest/270244#problem/R 给定一些人,问是否满足六度空间的要求。 著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即只用6个人就可以将他们联系在一起,因此他的理论也被称为“六度分离”理论(six degrees of separation)。 #include<bits/stdc++.h> using ...原创 2018-11-18 10:27:47 · 210 阅读 · 0 评论 -
Dijkstra最短路 (反向做+去重边)HDU - 2680
#include<stdio.h> #include<string.h> #define N 1500 #define INF 0x3f3f3f int n,t,f; int map[N][N]; int s[N]; int book[N]; int d[N]; void Dijkstra(int x) { int i,j; memset(book,0,s...原创 2018-11-18 09:18:01 · 439 阅读 · 0 评论 -
Dijkstra最短路 (构造0号顶点)HDU - 2680
http://acm.hdu.edu.cn/showproblem.php?pid=2680 给定很多个起点,一个终端,问起点到终点最短路径 转化:既然有多个路径,多次最短路?显然不行 这时候需要构造一个0号节点,且次节点与各个起点的距离为0,这样就可以求出起点到终端最短路径 #include<stdio.h> #include<iostream> #inclu...原创 2018-11-17 22:15:47 · 185 阅读 · 0 评论 -
HDU1875(Kruscal)畅通工程再续 (忘记把中间过程输出去掉,wa了N+1次)
http://acm.hdu.edu.cn/showproblem.php?pid=1875 #include<iostream> #include<math.h> #include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> using...原创 2018-11-19 20:05:20 · 204 阅读 · 0 评论 -
POJ1308 Is It A Tree? 并查集判断有向图是否为树
http://poj.org/problem?id=1308 无环 cnt=1 #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <string> #include <iostream> #include ...原创 2018-11-21 11:23:35 · 270 阅读 · 0 评论 -
最小生成树之kruskal (加边法)算法思想
n个节点,每两个节点都有权值,求一个树连接起来的最小权值 算法分析: 一.先把每个节点看成独立的图 二.先把每条边权值从小到大排序(利用结构体+sort排序),每次选取最短的边,看是否属于不同子图,若属于不同子图则加入,否则放弃(此处会用到并查集知识,利用自定义finds函数找寻是否属于不同图)。 三.重复二操作,直到找到n-1条边 #include<bits/stdc++.h&g...原创 2018-05-06 23:35:00 · 705 阅读 · 0 评论 -
最小生成树 P1546 最短网络 Agri-Net
题目背景 农民约翰被选为他们镇的镇长!他其中一个竞选承诺就是在镇上建立起互联网,并连接到所有的农场。当然,他需要你的帮助。 题目描述 约翰已经给他的农场安排了一条高速的网络线路,他想把这条线路共享给其他农场。为了用最小的消费,他想铺设最短的光纤去连接所有的农场。 你将得到一份各农场之间连接费用的列表,你必须找出能连接所有农场并所用光纤最短的方案。每两个农场间的距离不会超过100000 输...原创 2018-05-08 23:14:54 · 418 阅读 · 0 评论 -
Networking POJ1287 最小生成树 Kruscal (根据Kruscal特点,不用判断重边)
http://poj.org/problem?id=1287 给定点以及边,这里需要注意的是50个点最多,那么边最多有50*49条,注意数组不要太小了。 Kruscal模板题 #include<iostream> #include<math.h> #include<stdio.h> #include<string.h> #include<...原创 2018-11-18 21:33:59 · 243 阅读 · 0 评论 -
Networking POJ1287 最小生成树Prim(注意判断重边)或 kruscal不用判断重边
http://poj.org/problem?id=1287 prim #include<iostream> #include<math.h> #include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> #define maxn 10...原创 2018-11-18 21:49:51 · 430 阅读 · 0 评论 -
拓扑排序
一、什么是拓扑排序 在图论中,拓扑排序(Topological Sorting)是一个有向无环图(DAG, Directed Acyclic Graph)的所有顶点的线性序列。且该序列必须满足下面两个条件: 每个顶点出现且只出现一次。 若存在一条从顶点 A 到顶点 B 的路径,那么在序列中顶点 A 出现在顶点 B 的前面。 有向无环图(DAG)才有拓扑排序,非DAG图没有拓扑排序一说。 例如...转载 2018-11-12 23:51:32 · 201 阅读 · 0 评论 -
无向图割顶与桥
#include<cstdio> #include<cstring> #include<vector> using namespace std; const int maxn=100000+10; int n,m; int dfs_clock;//时钟,每访问一个节点增1 vector<int> G[maxn];//G[i]表示i节点邻接的所有节点...原创 2018-11-09 11:49:15 · 206 阅读 · 0 评论 -
树形dp入门(P1352 没有上司的舞会)
某大学有N个职员,编号为1~N。他们之间有从属关系,也就是说他们的关系就像一棵以校长为根的树,父结点就是子结点的直接上司。现在有个周年庆宴会,宴会每邀请来一个职员都会增加一定的快乐指数Ri,但是呢,如果某个职员的上司来参加舞会了,那么这个职员就无论如何也不肯来参加舞会了。所以,请你编程计算,邀请哪些职员可以使快乐指数最大,求最大的快乐指数。 输入输出格式 输入格式: 第一行一个整数N。(1&...原创 2018-08-23 23:13:42 · 367 阅读 · 0 评论 -
邻接矩阵和数组模拟邻接表
1.模拟邻接表 #include<bits/stdc++.h> #include<iostream> #include<cstdio> #include <cstring> using namespace std; const int E=100;//E为最大边数 const int N=100;//n为最大定点数 struct Edge { ...原创 2018-10-04 10:48:24 · 281 阅读 · 1 评论 -
POJ--Countries in War--强连通缩点+最短路
Countries in War Time Limit:1000MS Memory Limit:65536K Total Submissions:5406 Accepted:1554 Description In the year 2050, after different attempts of the UN to maintain peace...原创 2019-08-29 20:23:02 · 174 阅读 · 0 评论
分享