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

17962번 - Game on a Tree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB224988246.857%

문제

Alice and Bob play a game on a tree. Initially, all nodes are white.

Alice is the first to move. She chooses any node and put a chip on it. The node becomes black. After that players take turns. In each turn, a player moves the chip from the current position to an ancestor or descendant node, as long as the node is not black. This node also becomes black. The player who cannot move the chip looses.

Who wins the game?

An ancestor of a node v in a rooted tree is any node on the path between v and the root of the tree.

A descendant of a node v in a rooted tree is any node w such that node v is located on the path between w and the root of the tree.

We consider that the root of the tree is 1.

입력

The first line contains one integer n (1 ≤ n ≤ 100 000) — the number of nodes.

Each of the next n − 1 lines contains two integers u and v (1 ≤ u, v ≤ n) — the edges of the tree. It is guaranteed that they form a tree.

출력

In a single line, print “Alice” (without quotes), if Alice wins. Otherwise, print “Bob”.

제한

예제 입력 1

4
1 2
2 3
3 4

예제 출력 1

Bob

예제 입력 2

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

예제 출력 2

Alice

힌트

In the first test case, the tree is a straight line and has 4 nodes, so Bob always can choose the last white node.

In the second test case, the optimal strategy for Alice is to place the chip on 3. This node will become black. Bob has to choose the node 1. Alice can choose any of 4, 5, 6, or 7. Bob can only choose 2. Alice chooses any of the white sons of 2, and Bob cannot make a move.

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2019 F번

Contest > Open Cup > 2019/2020 Season > Stage 6: Grand Prix of Southeastern Europe F번

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

출처

대학교 대회

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

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