Editorial for ICPC NAQ 2016 B - Arcade!


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
  • This (zero-player) game is an example of a Markov chain.
  • For background, see Grinstead and Snell, Ch. 11.
  • Three solution approaches:
    1. Compute expected values via system of equations
    2. Compute absorption probabilities
    3. Simulate Markov chain for finite number of steps

Approach 1

  • Let Ei denote the expected payout if the ball is currently at hole i, and let ci denote the payout for dropping into hole i. Then: Ei=p4ci+p0Ea+p1Eb+p2Ec+p3Ed where a,b,c,d are the neighbors of hole i.
  • If H=N(N+1)/2 is the number of holes, this gives a system of H linear equations in H variables, which can be solved using Gaussian elimination in O(H3).
  • The input constraints imply that the system is consistent and has a unique solution.
  • Can be derived without knowing Markov chain theory.

Approach 2

  • Uses Markov chain theory directly.
  • Model each hole as a transient state, model falling into a hole as an absorbing state. Have H=N(N+1)/2 transient and H absorbing states.
  • Build H×H transition matrix Q, use Gaussian elimination to compute fundamental matrix N=(IQ)1.
  • Compute absorption probabilities B=NR where R is the H×H diagonal matrix Ri,j of being absorbed (falling into the hole) j when hovering over hole i.
  • Compute expected value as dot product of first row of B with expected payout. (Optimize to compute only first row of B.)

Approach 3

  • Keep track of probability of being over hole i after k steps: vector of pk,i elements.
  • For all i, compute pk+1,i from pk,i by simulating the next event of ball bouncing from hole i to possible neighbors.
  • Compute contribution to expected payout based on probability of falling into hole i at step k.
  • Stop when probability of not having been absorbed is small enough.
  • Caveat: if probabilities of falling into holes are very small, this could take many iterations: exploit problem constraint that the probability of not having been absorbed drops below threshold.
  • Mathematically equivalent to computing first row of NR=(IQ)1R=(I+Q+Q2+)R — but will time out if done using dense matrix!

Comments

There are no comments at the moment.