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

Making Friends

Platinum I 플래티넘 I
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

*Note: the time limit for this problem is 3s, 50% larger than the default.
The memory limit is twice the default.
*

There are initially \(M\) (\(1\le M\le 2\cdot 10^5\)) pairs of friends among FJ's
\(N\) (\(2\le N\le 2\cdot 10^5\)) cows labeled \(1\dots N\). The cows are leaving the
farm for vacation one by one. On day \(i\), the \(i\)-th cow leaves the farm, and
all pairs of the \(i\)-th cow's friends still present on the farm become friends.
How many new friendships are formed in total?

Problem credits: Benjamin Qi

제약

SCORING

  • Test cases 2-3 satisfy \(N\le 500\).
  • Test cases 4-7 satisfy \(N\le 10^4\).
  • Test cases 8-17 satisfy no additional constraints.

Problem credits: Benjamin Qi

입력 형식

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

The next \(M\) lines contain two integers \(u_i\) and \(v_i\) denoting that cows \(u_i\)
and \(v_i\) are friends (\(1\le u_i,v_i\le N\), \(u_i\neq v_i\)). No unordered pair
of cows appears more than once.

출력 형식

One line containing the total number of new friendships formed. Do not include pairs of cows that
were already friends at the beginning.

예제 1
입력
7 6
1 3
1 4
7 1
2 3
2 4
3 5
출력
5
설명

On day \(1\), three new friendships are formed: \((3,4)\), \((3,7)\), and \((4,7)\).

On day \(3\), two new friendships are formed: \((4,5)\) and \((5,7)\).

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2022-2023 > December > Platinum

태그

평가 및 의견

Making Friends

개요
출제자 난이도 Platinum I 플래티넘 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Making Friends

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