vatayush's blog

By vatayush, 9 years ago, In English

Hey i am tying to solve the problem from yesterday's contest.i am getting WA in 2nd test case.can someone please point a bug.i am unable to find one.here is my code

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

| Write comment?
»
9 years ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

dp[curr][(abs(l-d))] why do you think it is enough to know only abs(d-L) ? If d = 5 you have to consider both cases with L = 4, and with L = 5 not only one of them. Use dp[curr][360 + l - d]
UPD: there is mistake in the text. "both cases with L = 4, and with L = 6" abs(4-5) == abs(6-5)

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

    i guess dp[curr][abs(l-d)] takes care of this. if d=5,then l=4,5,6 and the dp states will be dp[9][1],dp[10][0],dp[11][1]. if i am incorrect please correct me!

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      in the example below func reaches island 1138 with L = 92 first, and for abs(100-92) == 8 remembers result 1. Then func reaches island 1138 with L = 108 and returns answer 1 because abs(100-108) == 8. It's wrong.

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

n = 2, d = 100
1138
1138+109
your answer is 1, but it's 2.