首页 > TAG信息列表 > nowVisit

1034 Head of a Gang (30 分)

One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all the phone calls made betw

强化阶段 Day 22 算法笔记 10.3 图的遍历

目录 1.Head of a Gang 2.邻接矩阵版bfs 3.邻接表 4.带层号 5.Forwards on Weibo 1.Head of a Gang #include<cstdio> #include<vector> #include<cstring> #include<string> #include<stack> #include<set> #include<map> #include<ctime&

Codeup100000620问题 A: 第一题

题目描述: 该题的目的是要你统计图的连通分支数。 输入: 每个输入文件包含若干行,每行两个整数i,j,表示节点i和j之间存在一条边。 输出: 输出每个图的联通分支数。 样例输入: 1 4 4 3 5 5 样例输出: 2 实现代码: #include<cstdio> #include<algorithm> #include<vector> using name

PAT A1034 Head of a Gang

通话记录有1000条,人数可能为2000给的人名是string,用两个map记录数字转换每遍历过一条边后就把这条边的权值设为0,防止出现回路遍历死循环 #include <cstdio> #include <vector> #include <iostream> #include <queue> #include <algorithm> #include <map> using namespace s

图的dfs+string的输入只能用cin

1034 Head of a Gang (30分) One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of