RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0659

Friendship Editing

Diamond IV 다이아몬드 IV
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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\).

Problem credits: Benjamin Qi

제약

SCORING

  • Inputs 4-13: One input for each \(N\in [6, 15]\) in increasing order.
  • Inputs 14-18: \(N=16\)

Problem credits: Benjamin Qi

입력 형식

The first line contains \(N\) and \(M\).

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

출력 형식

The number of edges you need to add or remove.

예제 1
입력
3 1
1 2
출력
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
출력
0
설명

No changes are necessary.

예제 3
입력
4 4
1 2
1 3
1 4
2 3
출력
1
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2024-2025 > February > Gold

태그

평가 및 의견

Friendship Editing

개요
출제자 난이도 Diamond IV 다이아몬드 IV 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Friendship Editing

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8