#K34672. Maximum Shield Strength
Maximum Shield Strength
Maximum Shield Strength
In the kingdom of Sphera, there are n cities connected by m roads. The roads are given as pairs of cities. The shield strength is defined as the maximum number of cities that can be chosen such that no two chosen cities are directly connected by a road. In other words, you need to find the size of the maximum independent set of the graph.
Formally, let \( S \subseteq \{1,2,\ldots,n\} \) be the set of selected cities. The set \( S \) is independent if for every road \((u,v)\), it holds that:
\[ \forall (u,v) \in R,\; \lnot\ (u \in S \; \text{and} \; v \in S) \]Your task is to compute the maximum size of such an independent set.
inputFormat
The input is read from standard input (stdin) and has the following format:
n m u1 v1 u2 v2 ... um vm
Here, the first line contains two integers: n
(the number of cities) and m
(the number of roads). Each of the following m
lines contains two integers u
and v
, denoting a road connecting city u
and city v
.
outputFormat
Output a single integer to standard output (stdout) representing the maximum shield strength, i.e., the size of the largest independent set.
## sample5 5
1 2
2 3
3 4
4 5
5 1
2