mdazmat9's blog

By mdazmat9, history, 4 years ago, In English

without creating reference variable of dp array — https://codeforces.com/contest/1271/submission/76026065 with creating reference variable of dp array — https://codeforces.com/contest/1271/submission/76032760

In one solution I am not creating reference variable ans inside rec function and solving normally gave WA while making reference variable gave AC .I am unable to find error in my both code rest parts are exactly same .Please look into 'rec' function and help me out . Thank you Problem link : https://codeforces.com/contest/1271/problem/D

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

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

Auto comment: topic has been updated by mdazmat9 (previous revision, new revision, compare).

»
4 years ago, # |
  Vote: I like it +14 Vote: I do not like it

The problem is that in the version without reference variable you are modifying k in rec function so at the time of returning you save the result at wrong position in the array. You can fix it by making a copy of the variable k before modifying it and when storing the result use this coy instead. Your Code with AC