NeoYL's blog

By NeoYL, 20 months ago, In English

i just wanna ask if anyone finished BOI 2015 bowling(super hard to me)and could share your solutions here? link to problem:https://oj.uz/problem/view/BOI15_bow the solution is probably dp, using the fact that the score is at most 300 but the transition states are just disgustingly complex or did anyone solve it using maths.

  • Vote: I like it
  • +6
  • Vote: I do not like it

»
20 months ago, # |
  Vote: I like it 0 Vote: I do not like it

my idea for subtask 3: since we know that there is no strikes or spares we know that scores are independent of each other frames, final score is basically summation of all frames. Then we get x1+x2+x3+x4+x5+....=final score(if not -1), since there is no frames with spare or strike, x1+x2<10, x3+x4<10 ..... so i just did some maths to get 9-x1-x2>=0, 9-x3-x4>=0, ...., then i used stars and bars to find that answer would just be (sum of points + number of frames-1) C (sum of points), then i would change it back to x1+x2+x3+x4+...., instead of 9-x1-x2>=0, 9-x3-x4>=0 ... but i couldn't pass subtask 3, did anyone have a similar approach to my subtask 3?

»
20 months ago, # |
  Vote: I like it 0 Vote: I do not like it

The first question is do you want to get it accepted on oj.uz, or on the original timelimits (being around 20x smaller) :P

On oj.uz there is a pretty neat solution doing dp[frame][score][next_throw][second_next_throw] = how many possibilities. You can update it without bigger problems, iterating over new next throws (since both throws in the current frame are already determines by the dp state, strike is a case that is easy to handle separately — you iterate over second next throw only). You will have to if out the last frame, but it's not so painful in this dp model. It looks pretty slow, but actually with some optimizations (like breaking if score is too high to be ever achieved or if score/throws are contradicting with input) you can get it under 1 second.

The original solution does dp[frame][score][prev_strikes] where prev_strikes is information about strikes/spares in last two rounds and score is the score without bonuses from next throws. It checks if score is not contradicting with input later, when dp is used. So basically you look at previous strikes and spares, calculate what were the real previous two scores (not the ones in dp), check if they are not contradicting with the input, and then update the dp. Yes, that's a lot of cases you have to handle, which gets scary, but there is not "neat" way around that. If you are interested in the code, you can find it here

  • »
    »
    20 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    ok thx for answering (getting absolutely destroyed by dp) xd