#C8480. Tree Color Game

    ID: 52467 Type: Default 1000ms 256MiB

Tree Color Game

Tree Color Game

In this problem, you are given a tree with ( n ) nodes. Each node is painted either red (denoted by 'R') or blue (denoted by 'B'). Starting from node 1, two players, Bob and Alice, traverse the tree in a breadth-first order. Bob starts first. When Bob visits a node and its color is red, he scores a point; when Alice visits a node and its color is blue, she scores a point. The players alternate turns as they traverse the tree. Your task is to determine the winner. If Bob's score is greater than Alice's score, Bob wins; if Alice's score is greater, then Alice wins; otherwise, the game results in a draw.

The scoring rules can be summarized as follows:

  • If a node is visited by Bob and its color is ( R ), Bob's score increments by 1.
  • If a node is visited by Alice and its color is ( B ), Alice's score increments by 1.

Finally, compare the scores: if ( score_{Bob} > score_{Alice} ), output "Bob"; if ( score_{Alice} > score_{Bob} ), output "Alice"; otherwise, output "Draw".

inputFormat

The input is read from standard input (stdin) and consists of multiple lines:

  • The first line contains an integer ( n ) indicating the number of nodes in the tree.
  • The second line contains a string of length ( n ) where each character is either 'R' or 'B', representing the color of each node (1-indexed).
  • The next ( n-1 ) lines each contain two space-separated integers ( u ) and ( v ), representing an edge between nodes ( u ) and ( v ) in the tree.

outputFormat

Output a single line to standard output (stdout) containing one of the following strings: "Alice", "Bob", or "Draw", indicating the winner of the game based on the rules described.## sample

3
RBR
1 2
2 3
Bob