
图论
文章平均质量分 88
qq_30339595
人类,诗意地栖息在大地上。
展开
-
I Wanna Go Home
时间限制:1秒 空间限制:65536K 热度指数:613 算法知识视频讲解题目描述 The country is facing a terrible civil war----cities in the country are divided into two parts supporting different leaders. As a merchant, Mr. M does not ...原创 2018-02-15 22:51:26 · 409 阅读 · 0 评论 -
算法题 :比较重量
题目:小明陪小红去看钻石,他们从一堆钻石中随机抽取两颗并比较她们的重量。这些钻石的重量各不相同。在他们们比较了一段时间后,它们看中了两颗钻石g1和g2。现在请你根据之前比较的信息判断这两颗钻石的哪颗更重。给定两颗钻石的编号g1,g2,编号从1开始,同时给定关系数组vector,其中元素为一些二元组,第一个元素为一次比较中较重的钻石的编号,第二个元素为较轻的钻石的编号。最后给定之前的比较次数n。请返...原创 2018-02-25 22:31:56 · 522 阅读 · 0 评论 -
欧拉回路
欧拉回路存在条件:除孤岛节点外,其他节点连通且度为偶数。有向图的条件是所有点出入度相同。时间限制:1秒 空间限制:65536K 热度指数:1183 算法知识视频讲解题目描述 欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路。现给定一个图,问是否存在欧拉回路?输入描述: 测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是节点数N ( 1 &l...原创 2018-02-10 16:15:15 · 187 阅读 · 0 评论 -
找出直系亲属
时间限制:1秒 空间限制:65536K 热度指数:368 算法知识视频讲解题目描述 如果A,B是C的父母亲,则A,B是C的parent,C是A,B的child,如果A,B是C的(外)祖父,祖母,则A,B是C的grandparent,C是A,B的grandchild,如果A,B是C的(外)曾祖父,曾祖母,则A,B是C的great-grandparent,C是A,B的great-grandchi...原创 2018-03-04 16:47:30 · 218 阅读 · 0 评论 -
最短路径(并查集+kruskal最小生成树)
时间限制:1秒 空间限制:65536K 热度指数:1293 算法知识视频讲解题目描述N个城市,标号从0到N-1,M条道路,第K条道路(K从0开始)的长度为2^K,求编号为0的城市到其他城市的最短距离输入描述:第一行两个正整数N(2<=N<=100)M(M<=500),表示有N个城市,M条道路接下来M行两个整数,表示相连的两个城市的编号输出描述:N-1行,表示0号城市到其他城市的...原创 2018-03-03 22:23:51 · 856 阅读 · 0 评论 -
Is It A Tree?
题目描述A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties. The...原创 2018-02-22 13:48:55 · 948 阅读 · 0 评论 -
拓扑排序求关键路径
#include "stdafx.h"#include<cstdio>#include<iostream>#include<vector>#include<stack>#include<queue>using namespace std;const int maxn=100;const int inf=0x7ffffff...原创 2018-03-15 15:49:21 · 347 阅读 · 0 评论 -
SPFA算法判断是否有负环
#include "stdafx.h"#include<cstdio>#include<iostream>#include<vector>#include<cstring>#include<queue>using namespace std;const int maxn=100;const int inf=0x7ffff...原创 2018-03-15 15:05:32 · 523 阅读 · 0 评论 -
PAT 1139. First Contact
1139. First Contact 这道题目注意点:1.用字符串读入人的编号,因为如果用int,当输入-0000和0000时无法判断性别2.用邻接表存图,为防止内存超限3.可能这个人要表白的人正好是他的朋友。4.两个set两层遍历的时候,for(it=a.begin();it!=a.end();it++)for(it1=b.begin();it1!=b.end();it1++)//#inclu...原创 2018-03-14 12:53:37 · 516 阅读 · 0 评论