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

16269번 - Nice Report 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB226621110.891%

문제

Andrew is analyzing subscription graph in one social network. This graph is directed: if the user a is subscribed to the user b, it is not always the case that the user b is in turn subscribed to the user a.

Andrew's boss has asked him to find for each user x the number of users y such that it is possible to reach user y from user x in the subscription graph.

There is no reason to find the exact values, they look ugly and are non-relevant almost immediately, so Andrew wants to find approximate values. Find values that differ from the correct ones at most by a factor of two.

입력

The first line of input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of users of the social network and the number of direct subscriptions.

The following m lines describe subscription graph, the i-th of these lines contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi), it means that the user ai is subscribed to the user bi. Each ordered pair (ai, bi) occurs at most once in the input data.

출력

Output n integers qi — for each user print approximate number of users y such that it is possible to reach user y from user i in the subscription graph. If the correct number of such users is zi, the following inequalities must be satisfied to have the answer accepted: qi ≤ 2zi and zi ≤ 2qi. Moreover, you are allowed to bypass this restriction and output any qi for no more than 10 users.

Note: judges use exact values to check your answers. However, judges don't promise that it is possible to find exact values in each test case given time and memory constraints of this problem. They recommend to try to find approximate value.

In the given example it is possible to reach all five users from the user 1. But the given answer 7 is acceptable, it differs from 5 less than by a factor of two. Similarly, the answer 2 is acceptable for the user 4.

제한

예제 입력 1

5 6
1 2
1 3
2 4
2 5
3 5
4 2

예제 출력 1

7
3
2
2
1

힌트

출처

Contest > Russian Code Cup > 2017 > RCC 2017 Third Qualification Round E번

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

출처

대학교 대회

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

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