No.977 The Alice-Rigged Skyscraper
タグ : / 解いたユーザー数 303
作問者 :
ngtkana
/ テスター :
tempura_pp
Problem Statement
In a coffee shop, Alice and Bob were playing the game of love.
The kingdom has $N$ islands and $N - 1$ bridges, each indexed starting from 0. The $i$-th bridge connects the $u_i$-th island and the $v_i$-th island. This is not necessarily a tree, but there are no self-loops or multiple edges.
Alice goes first. Alice wants to make the kingdom disconnected. She can choose any one bridge and blow it up.
Bob goes second. Bob wishes for peace, so he wants to make the kingdom connected. After seeing Alice's mischief, he can choose two distinct islands with no bridge between them and build one bridge between them.
After both of them have finished their operations, Alice wins if the kingdom is disconnected, and Bob wins if it is connected. Print 'Alice' on one line if Alice wins, or 'Bob' if Bob wins.
(Added at 21:27: Alice can destroy exactly one bridge, and Bob can build exactly one bridge.)
Constraints
The input consists of $N$ lines in total and satisfies the following constraints.
- $2 \leq N \leq 10^5$
- $0 \leq u_i, v_i < N \ (0 \leq i < N-1)$
- $u_i \neq v_i \ ( 0 \leq i < N - 1)$
- $\{u_i, v_i\} \neq \{u_j, v_j\} \ ( i \neq j) $
Input
$N$
$u_0\ v_0$
$\dots$
$u_{N - 2}\ v_{N - 2}$
The first line gives the number of islands $N$.
The following $N - 1$ lines give the information on the bridges. Bridge $i (i = 0, \dots , N - 2)$ connects island $u_i$ and island $v_i$.
Output
Print "Alice" or "Bob" on one line.
Print a newline at the end.
Sample
Sample 1
Input
3 0 1 1 2
Output
Bob
Whichever bridge Alice blows up, Bob can make Yukiko City connected again.
Sample 2
Input
7 0 1 0 2 0 3 1 2 1 3 2 3
Output
Alice
For example, when Alice blows up the bridge connecting island $0$ and island $1$, Bob cannot make Yukiko City connected again. Note that islands $4, 5, 6$ exist, although they are isolated.
Sample 3
Input
7 0 1 1 2 2 3 2 4 3 4 4 5
Output
Alice
Boooo! Alice wins!
Think about why you lost until tomorrow.
Then you should start to see something.
Well then, time to blow it up.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。