포럼
문제 ICPC00190

B. Brexit Negotiations

설명

As we all know, Brexit negotiations are on their way—but we still do not know whether they will actually finish in time.

The negotiations will take place topic-by-topic. To organise the negotiations in the most effective way, the topics will all be discussed and finalised in separate meetings, one meeting at a time.

This system exists partly because there are (non-cyclic) dependencies between some topics: for example, one cannot have a meaningful talk about tariffs before deciding upon the customs union. The EU can decide on any order in which to negotiate the topics, as long as the mentioned dependencies are respected and all topics are covered.

Each of the topics will be discussed at length using every available piece of data, including key results from past meetings. At the start of each meeting, the delegates will take one extra minute for each of the meetings that has already happened by that point, even unrelated ones, to recap the discussions and understand how their conclusions were reached. See Figure for an example.

Nobody likes long meetings. The EU would like you to help order the meetings in a way such that the longest meeting takes as little time as possible.

제약
입력 형식

The input consists of:
- One line containing an integer \(n\) (\(1 \leq n \leq 4 \cdot 10^5\)), the number of topics to be discussed. The topics are numbered from \(1\) to \(n\).
- \(n\) lines, describing the negotiation topics.

The \(i\)th such line starts with two integers \(e_i\) and \(d_i\) ($1 \leq e_i \leq
10^6\(, \)0 \leq d_i < n\(), the\ number\ of\ minutes\ needed\ to\ reach\ a\ conclusion\ on\ topic \)i\( and\ the\ number\ of\ other\ specific\ topics\ that\ must\ be\ dealt\ with\ before\ topic \)i$ can be discussed.

The remainder of the line has \(d_i\) distinct integers \(b_{i,1}, \ldots, b_{i,d_{i}}\) (\(1 \le b_{i,j} \le n\) and \(b_{i,j} \ne i\) for each \(j\)), the list of topics that need to be completed before topic \(i\).

It is guaranteed that there are no cycles in the topic dependencies, and that the sum of \(d_i\) over all topics is at most \(4 \cdot 10^5\).

출력 형식

Output the minimum possible length of the longest of all meetings, if meetings are arranged optimally according to the above rules.

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

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

출처 ICPC NWERC 2018

평가 및 의견

B. Brexit Negotiations

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

Log in to rate problems.

개별 의견

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

풀이 제출

B. Brexit Negotiations

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