포럼
문제 ICPC00306

I. Instagraph

설명

A celebrity in a social network is somebody with many followers, but who doesn't follow them back. More precisely, a person is a celebrity for a group of people, if
- every member of the group follows the person,
- the person follows nobody in the group.

The celebrity centrality of person \(v\), written \(\mathrm{CC}(v)\), is the maximum size of such a group.

We model the social network as a directed graph with \(N\) vertices \(1\), \(\ldots\), \(N\). A directed edge from \(u\) to \(v\) means that person \(u\) follows person \(v\). For example, in

we have \(\operatorname{CC}(1) = 0\), \(\operatorname{CC}(2) = 1\), and \(\operatorname{CC}(5) = 2\).

Your task is to find a vertex \(v\) with the maximum celebrity centrality \(\mathrm{CC}(v)\). In case of a tie, choose the smallest \(v\).

제약
입력 형식

The input consists of
- One line with two integers \(N\) and \(M\) (\(1 \le N \le 200\,000\), \(0 \le M \le 1\,000\,000\)), the number of vertices and the number of directed edges.
- \(M\) lines with two distinct integers \(u\) and \(v\) (\(1 \le u,v \le N\)), indicating a directed edge from \(u\) to \(v\). There are no duplicate edges.

출력 형식

Output two integers: the smallest \(v\) with the maximum celebrity centrality and the value \(\mathrm{CC}(v)\).

예제 1
입력
6 8
1 2
2 1
2 3
3 2
3 6
4 5
5 2
6 5
출력
5 2
예제 2
입력
1 0
출력
1 0
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2025

평가 및 의견

I. Instagraph

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

I. Instagraph

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