Easylife

4.8

17 votes
Algorithms, Depth First Search, Easy, Graphs
Problem

Given an undirected graph. Density of a graph is |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 (1n105, 0m2105).

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

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

n17, m50 - 15 points.

n17, m2105 - 10 points.

n70, m200 - 20 points.

n70, m2105 - 5 points.

n105, m2105 - 50 points.

Sample Input
5 3
1 4
2 3
5 2
Sample Output
2/3
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

The best option is to choose vertices 2, 3 and 5.

Editor Image

?