Logo
(追記) (追記ここまで)

33731번 - Friendship Editing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB149975.000%

문제

Farmer John's $N$ cows are labeled 1ドル$ to $N$ (2ドル\le N\le 16$). The friendship relationships between the cows can be modeled as an undirected graph with $M$ (0ドル\le M\le N(N-1)/2$) edges. Two cows are friends if and only if there is an edge between them in the graph.

In one operation, you can add or remove a single edge from the graph. Count the minimum number of operations required to ensure that the following property holds: If cows $a$ and $b$ are friends, then for every other cow $c,ドル at least one of $a$ and $b$ is friends with $c$.

입력

The first line contains $N$ and $M$.

The next $M$ lines each contain a pair of friends $a$ and $b$ (1ドル\le a<b\le N$). No pair of friends appears more than once.

출력

The number of edges you need to add or remove.

제한

예제 입력 1

3 1
1 2

예제 출력 1

1

The network violates the property. We can add one of edges $(2,3)$ or $(1,3),ドル or remove edge $(1,2)$ to fix this.

예제 입력 2

3 2
1 2
2 3

예제 출력 2

0

No changes are necessary.

예제 입력 3

4 4
1 2
1 3
1 4
2 3

예제 출력 3

1

힌트

출처

Olympiad > USA Computing Olympiad > 2024-2025 Season > USACO 2025 February Contest > Gold 3번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /