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

27045번 - Popular Cows 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB110686361.165%

문제

Every cow's dream is to become the most popular cow in the herd. In a herd of N (1 ≤ N ≤ 10,000) cows, you are given up to M (1 ≤ M ≤ 50,000) ordered pairs of the form (A, B) that tell you that cow A thinks that cow B is popular. Since popularity is transitive, if A thinks B is popular and B thinks C is popular, then A will also think that C is popular, even if this is not explicitly specified by an ordered pair in the input. Your task is to compute the number of cows that are considered popular by every other cow.

입력

  • Line 1: Two space-separated integers, N and M
  • Lines 2..1+M: Two space-separated numbers A and B, meaning that A thinks B is popular.

출력

  • Line 1: A single integer that is the number of cows who are considered popular by every other cow.

제한

예제 입력 1

3 3
1 2
2 1
2 3

예제 출력 1

1

힌트

Cow 3 is the only cow of high popularity.

출처

Olympiad > USA Computing Olympiad > 2003-2004 Season > USACO November 2003 Contest > Green 3번

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

출처

대학교 대회

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

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