[Modified] fix a bug in dp