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

G. Parmigiana With Seafood

설명

The “Parmigiana di melanzane” is a typical Italian dish. Alessandro and Bianca have very different tastes when it comes to it: Alessandro loves to eat Parmigiana with seafood, but Bianca thinks it is an atrocity! To decide which ingredients to include in the dish they prepare, they play the following game. There are \(n\) possible ingredients, labeled from 1 to \(n\). The higher the label, the closer the ingredient is to being seafood. The ingredients are connected by \(n - 1\) edges, in such a way as to form a tree. Alessandro and Bianca take turns, with Alessandro going first. They alternately choose a terminal ingredient \(x\), that is an ingredient currently connected to at most one other ingredient, and remove it from the tree. If the terminal ingredient \(x\) was chosen by Alessandro, it goes in the recipe; if it was chosen by Bianca, it is discarded. The taste of the Parmigiana is measured as the maximum label of an ingredient in the recipe. Alessandro wants to maximize the taste, while Bianca wants to minimize the taste. If both play optimally, what is the taste of the Parmigiana?

제약
입력 형식

The first line contains an integer \(n\) (\(2 \le n \le 100\,000\)) — the number of ingredients. Each of the following \(n - 1\) lines contain two integers \(u_{i}\) and \(v_{i}\) (\(1 \le u_{i}\), \(v_{i} \le n\), \(u_{i}\)̸ = \(v_{i}\)) — the ingredients that the \(i-th\) edge connects. It is guaranteed that the edges form a tree (i.e., any pair of ingredients is connected by the edges, possibly indirectly).

출력 형식

Print the value of the taste if both Alessandro and Bianca play optimally.

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

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

출처 ICPC SWERC 2022

평가 및 의견

G. Parmigiana With Seafood

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

Log in to rate problems.

개별 의견

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

풀이 제출

G. Parmigiana With Seafood

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