Блог пользователя sentinel45

Автор sentinel45, 14 лет назад, По-английски

the following code is my soln to 38E - Let's Go Rolling!

i m using memoization in table

k is the index of last index to be pinned

and

in is the value of index for which decision will be made

the submission can be found here.. http://www.codeforces.com/contest/38/submission/1811242

plz help...optimizing my code or any general useful suggestions regarding implementation of dp..

thanx..

Теги 38e
  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
14 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

Try to use other "empty" value, not just zero. memset(table, 0x05, sizeof(table));... if(table[in][k] != 0x05050505) ...
BTW, are you sure is this conversion (compfn)cmp correct?
And use long long answer can be larger than 2^32

»
14 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

ohh, i figured it out...

the answer for test 18 was zero... so every entry was supposed to be equal to zero... and my table was initialized to zero as well..!!! ths led the algorithm to exponential tym coz memoization was rendered useless...

gosh..!!! lesson of a lyftym...:)

thnx guys goo.gl_SsAhv and dalex