#P8874. ChuanZhi Monopoly Simulation
ChuanZhi Monopoly Simulation
ChuanZhi Monopoly Simulation
In this customized monopoly game there are n cells arranged in a circle numbered 1,2,…,n in anticlockwise order. Two players, Lianzi and Meili, both start at cell 1 with an initial fund m.
Each round consists of two moves (first Lianzi then Meili). In each move the active player rolls a die which shows a number k. Then the player moves exactly k steps in the anticlockwise direction. For every cell passed (each step of the move), if the cell has a building, the following happens:
- If the building belongs to the mover, the mover receives an amount equal to the building’s current value \(a_i\).
- If the building belongs to the opponent, the mover must transfer \(a_i\) funds from his own funds to the opponent.
After completing the movement the player is at the final cell and may perform a sequence of building operations provided in the input. The operations are processed in order:
- If the cell has no building and the player chooses operation 0, then if the player’s funds are at least \(C_{i,0}\) the player spends \(C_{i,0}\) to build a new building on that cell; the building is initialized to level 0 with its value \(a_i = C_{i,0}\). (If funds are insufficient, the cost is still deducted causing the funds to become negative and the game immediately ends.)
- If the cell already has a building owned by the player and the player chooses operation 1, and if the building’s current level is less than the maximum level \(L\), then the player may upgrade it. Upgrading costs \(C_{i,j}\) where \(j\) is the current level. On paying the cost, the building’s value is increased by \(C_{i,j}\) and its level increases by 1. (Again, if funds are insufficient, the cost is deducted and the funds become negative, ending the game.)
After a move the control is passed to the other player. Once both players have moved (i.e. one round is completed), each cell with a building provides its bonus: the building on cell i adds \(d_i\) to its owner’s funds.
The game terminates immediately when, during any move (or after bonus distribution) a player’s funds become negative; that player is declared the loser. Given q rounds of moves (each move specifying the dice outcome and the list of operations), determine who loses the game.
Note: All formulas are given in \(\LaTeX\) format.
inputFormat
The input begins with a line containing four integers n, m, L and q where:
- n: number of cells on the board.
- m: initial funds for each player.
- L: maximum building level (buildings start at level 0).
- q: number of rounds to process.
The second line contains n integers \(d_1, d_2, \dots, d_n\) where \(d_i\) is the bonus provided by a building on cell i during the distribution phase.
Then follow n lines, each containing L integers. The i-th of these lines provides the costs \(C_{i,0}, C_{i,1}, \dots, C_{i,L-1}\). Here, \(C_{i,0}\) is both the cost to build on an empty cell i and the cost to upgrade a level 0 building on cell i, \(C_{i,1}\) is the cost to upgrade a level 1 building, and so on.
After that, there are 2q move descriptions (each round consists of two moves in order: first Lianzi then Meili). Each move is described as follows:
- A line containing two integers: k (the dice outcome) and t (the number of operations).
- If t > 0, the next line contains t space-separated integers. Each integer is either
0
(attempt to build) or1
(attempt to upgrade).
You may assume that the provided operations (if valid) will be executed in the given order. However, if at any point the player’s funds are not sufficient to cover an operation, the cost is still deducted, and the funds become negative, ending the game immediately.
outputFormat
Output a single line containing the name of the loser. Print Lianzi
if Lianzi loses, or Meili
if Meili loses. If no player ever loses (i.e. no funds become negative), you may output Draw
.
sample
3 10 2 2
2 1 3
5 4
3 2
6 5
2 1
0
3 1
0
1 1
1
2 2
0 1
Meili