![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图
文章平均质量分 65
RIPwangh
山东理工大学本科学生
展开
-
图结构练习——判断给定图是否存在合法拓扑序列
题目描述 给定一个有向图,判断该有向图是否存在一个合法的拓扑序列。输入 输入包含多组,每组格式如下。第一行包含两个整数n,m,分别代表该有向图的顶点数和边数。(n后面m行每行两个整数a b,表示从a到b有一条有向边。 输出 若给定有向图存在合法拓扑序列,则输出YES;否则输出NO。 示例输入1 02 21 22 1示例输出原创 2015-06-15 10:07:50 · 726 阅读 · 0 评论 -
SDUTOJ3361-数据结构实验之图论四:迷宫探索
#include #include #include #include #include using namespace std;int n, m, s;bool mp[1010][1010];int ph[1100];int vis[1100];int cnt;void creat(){ memset(mp,0,sizeof(mp)); int u, v;原创 2015-12-04 18:00:01 · 539 阅读 · 0 评论 -
2015网络赛&HDU5444 Elven Postman - 排序二叉树
题目意思: 给你一组排序二叉树,让你输出节点的方向,小的是E,大的是WCODE#include#include#include#include#includeusing namespace std;struct node{ int x; struct node *l, *r;};char mp[1010][1010];node *head;voi原创 2015-09-17 21:29:48 · 418 阅读 · 0 评论 -
poj-1094-Sorting It All Out-拓扑排序
DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequence原创 2015-08-06 16:41:12 · 445 阅读 · 0 评论 -
3687-Labeling Balls-反向拓扑排序
Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 toN in such a way that: No two balls share the same label.The labeling satisfies several constrain原创 2015-08-06 19:45:05 · 518 阅读 · 0 评论 -
poj-3020-Antenna Placement-二分图
DescriptionThe Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they got the job, is their disco转载 2015-08-07 10:09:40 · 757 阅读 · 0 评论 -
poj-3253-sdutoj-2127-哈夫曼树-优先队列
DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needsN (1 ≤ N ≤ 20,000) planks of wood, each having some integer le原创 2015-08-11 18:39:57 · 546 阅读 · 0 评论 -
poj -2513-Colored Sticks-哈希&并查集或者字典树&并查集
题意:给你任意条木棍,读到文件结束输入结束,木棍两边有颜色,相同颜色的可以连到一起,问是否可以连成一个欧拉路,这道题看着有两种做法1. 哈希&并查集 做法是字符串哈希,去判断奇数度的个数,个数大于等于3的话是代表不能形成一个欧拉路的,小于3的话,就看一下并查集,看是否这几个点是一个图上的,2. 字典树&并查集 做法略显麻烦,原因在于建字典树吧,其他的与上遍的做法相似原创 2015-08-12 14:32:01 · 497 阅读 · 0 评论 -
POJ-2418-Hardwood Species-字典树
统计各个单词占得比例#include#include#include#include#includeusing namespace std;int top, t=0;struct node{ int next[130]; int n;}pos[3500];struct nod{ char s[35]; int num;}ls[120原创 2015-08-13 20:12:46 · 383 阅读 · 0 评论 -
HDU 3729-I'm Telling the Truth-周赛4补题-二分图最大匹配-邻接表
题意: 新学期开学,老师想知道各个同学的分数,同学们不想把自己的真实分数告诉老师,只和老师说自己的排名在哪个范围内,有些同学和老师说的数据是不真实的,现在让你找到说的信息是真的同学的数目和序号,有多种情况要选择序号字典序大那种,注意,每个排名只有一个同学思路: 二分图的最大匹配; 要注意是要字典序大的,所以要反着搜CODE#include#include原创 2015-08-24 10:12:56 · 554 阅读 · 0 评论 -
poj-3041-Asteroids -二分图的最大匹配
Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which are conveniently locate原创 2015-08-07 09:18:04 · 560 阅读 · 0 评论 -
SDUT 数据结构 欧拉回路
无向图: 度数为偶数,且联通#include #include #include #include #include #define MAX 0x3f3f3fusing namespace std;int d[1100];int f[1100];int fd(int x){ return f[x] == x? x: f[x] = (fd(f[x]));}v原创 2015-12-04 19:30:48 · 503 阅读 · 0 评论