E - Independence
Time limit : 2sec / Memory limit : 1024MB
Score : 700 points
Problem Statement
In the State of Takahashi in AtCoderian Federation, there are N N cities, numbered . M M bidirectional roads connect these cities. The -th road connects City Ai A i and City Bi B i . Every road connects two distinct cities. Also, for any two cities, there is at most one road that directly connects them.
One day, it was decided that the State of Takahashi would be divided into two states, Taka and Hashi. After the division, each city in Takahashi would belong to either Taka or Hashi. It is acceptable for all the cities to belong Taka, or for all the cities to belong Hashi. Here, the following condition should be satisfied:
- Any two cities in the same state, Taka or Hashi, are directly connected by a road.
Find the minimum possible number of roads whose endpoint cities belong to the same state. If it is impossible to divide the cities into Taka and Hashi so that the condition is satisfied, print -1
.
Constraints
2≤N