P2987 [USACO10MAR] StarCowraft G

题目描述

The beta version of StarCowraft II is ready! Farmer John and Bessie are testing it, trying different strategies in one-on-one battles against each other's armies. The goal in StarCowraft II is to defeat your opponent's army in a battle. Each player's army fights in a battle. An army comprises as many as three different types of 'units' with respective strengths denoted by constant positive real numbers unknown to the players: cattlebruisers with strength S1, cow templars with strength S2, and ultracows with strength S3. The only given bounding information is that no unit is more than 100 times as strong as any another unit. An army's total strength is the sum of the individual strengths of each of its units. An army that has, among others units, 23 cattlebruisers would gain 23\*S1 strength just from the cattlebruisers. When two opposing armies fight in a battle, the army with a higher total strength value wins. If the armies have exactly equal strength values, one of the players randomly wins. Farmer John and Bessie played N (0

输入格式

\* Line 1: Two space-separated integers: N and M \* Lines 2..N+1: Line i+1 describes a test battle with seven space-separated items -- a victory letter and six space-separated integer unit counts: V\_i, J1\_i, J2\_i, J3\_i, B1\_i, B2\_i, and B3\_i \* Lines N+2..N+M+1: Line i+N+1 describes a 'new battle' using six space-separated integers: J1\_i, J2\_i, J3\_i, B1\_i, B2\_i, and B3\_i

输出格式

\* Lines 1..M: Line i contains the outcome of the i-th new battle: 'J' if Farmer John definitely wins, 'B' if Bessie definitely wins, and 'U' (undecidable) if it is impossible to decide the winner with the given information.

说明/提示

First two games correspond to the examples in the description. The result of the last game cannot be determined with only the information that Farmer John and Bessie currently have. Specifically, both S\_1=9.0, S\_2=7.0, S\_3=4.0 and S\_1=12.0, S\_2=20.0, S\_3=10.0 are consistent with the "test battles," but they give different results when plugged in the third "new battle."