问题
原题戳这 <<
Time limit : 2sec / Memory limit : 256MB
Score : 300 points
Problem Statement
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges.
The i-th edge (1≤i≤M) connects Vertex ai and Vertex bi.
An edge whose removal disconnects the graph is called a bridge.
Find the number of the edges that are bridges among the M edges.
Notes
A self-loop is an edge i such that ai=bi (1≤i≤M).
Double edges are a pair of edges i,j such that ai=aj and bi=bj (1≤i
Constraints
2≤N≤50
N−1≤M≤min(N(N−1)⁄2,50)
1≤ai< bi≤N
The given graph does not contain self-loops and double edges.
The given graph is connected.
Sample Input 1
7 7
1 3
2 7
3 4
4 5
4 6
5 6
6 7
Sample Output 1
4

题解
题意,给你n个点m条边,要求去掉一个边,无向图是否连通。
代码1
这个是我无数次RE后,无数次修改,发现用queue判断是否是连通比dfs判断快?反正以后就用queue了。
时间复杂度:O(m^2)
#include<cstdio>
#include<queue>
using namespace std;
bool ma[55][55];
int n,m;
bool solve()
{
//判断图是否连通
bool vis[55]={
0};



被折叠的 条评论
为什么被折叠?



