Easylife
Practice
4.8 (17 votes)
Algorithms
Depth first search
Easy
Graphs
Problem
91% Success 4893 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Given an undirected graph. Density of a graph is \(\frac{|E|}{|V|}\). Your task is to choose non-empty set of vertices V such that subgraph induced on V has maximal density and print this density. But if maximal density is strictly greater than 1, just print ">1".

Input format

The first line of input contains two integers n and m - number of edges and vertices in the graph, respectively (\(1 \le n \le 10^{5}\), \(0 \le m \le 2 \cdot 10^{5}\)).

Then m lines with edge descriptions follows. Each line contains two integers u, v - vertices incident to this edge (\(1 \le u, v \le n\), \(u \ne v\)).

Output format

If maximal density of a subgraph is not bigger than 1, then print it as irreducible fraction. Otherwise, print ">1" (without quotes).

Scoring

\(n \le 17\), \(m \le 50\) - 15 points.

\(n \le 17\), \(m \le 2 \cdot 10^{5}\) - 10 points.

\(n \le 70\), \(m \le 200\) - 20 points.

\(n \le 70\), \(m \le 2 \cdot 10^{5}\) - 5 points.

\(n \le 10^{5}\), \(m \le 2 \cdot 10^{5}\) - 50 points.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
66 votes
Tags:
ApprovedDepth First SearchDisjoint setEasyGraphsOpen
Points:20
25 votes
Tags:
AlgorithmsDepth First SearchEasyGraphsTrees
Points:20
37 votes
Tags:
AlgorithmsApprovedBacktrackingDepth First SearchEasyGraphsOpenRecursion