CF1404B.Tree Tag

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alice and Bob are playing a fun game of tree tag.

The game is played on a tree of nn vertices numbered from 11 to nn . Recall that a tree on nn vertices is an undirected, connected graph with n1n-1 edges.

Initially, Alice is located at vertex aa , and Bob at vertex bb . They take turns alternately, and Alice makes the first move. In a move, Alice can jump to a vertex with distance at most dada from the current vertex. And in a move, Bob can jump to a vertex with distance at most dbdb from the current vertex. The distance between two vertices is defined as the number of edges on the unique simple path between them. In particular, either player is allowed to stay at the same vertex in a move. Note that when performing a move, a player only occupies the starting and ending vertices of their move, not the vertices between them.

If after at most 1010010^{100} moves, Alice and Bob occupy the same vertex, then Alice is declared the winner. Otherwise, Bob wins.

Determine the winner if both players play optimally.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t1041 \le t \le 10^4 ). Description of the test cases follows.

The first line of each test case contains five integers n,a,b,da,dbn,a,b,da,db ( 2n1052\le n\le 10^5 , 1a,bn1\le a,b\le n , aba\ne b , 1da,dbn11\le da,db\le n-1 ) — the number of vertices, Alice's vertex, Bob's vertex, Alice's maximum jumping distance, and Bob's maximum jumping distance, respectively.

The following n1n-1 lines describe the edges of the tree. The ii -th of these lines contains two integers uu , vv ( 1u,vn,uv1\le u, v\le n, u\ne v ), denoting an edge between vertices uu and vv . It is guaranteed that these edges form a tree structure.

It is guaranteed that the sum of nn across all test cases does not exceed 10510^5 .

输出格式

For each test case, output a single line containing the winner of the game: "Alice" or "Bob".

输入输出样例

  • 输入#1

    4
    4 3 2 1 2
    1 2
    1 3
    1 4
    6 6 1 2 5
    1 2
    6 5
    2 3
    3 4
    4 5
    9 3 9 2 5
    1 2
    1 6
    1 9
    1 3
    9 5
    7 9
    4 8
    4 3
    11 8 11 3 3
    1 2
    11 9
    4 9
    6 5
    2 10
    3 2
    5 9
    8 3
    7 4
    7 10

    输出#1

    Alice
    Bob
    Alice
    Alice

说明/提示

In the first test case, Alice can win by moving to vertex 11 . Then wherever Bob moves next, Alice will be able to move to the same vertex on the next move.

In the second test case, Bob has the following strategy to win. Wherever Alice moves, Bob will always move to whichever of the two vertices 11 or 66 is farthest from Alice.

首页