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

Автор skpro19, история, 7 лет назад, По-английски

The question is 459C.

I have understood the logic behind it. But, in order to generate the possible permutations, I am using DFS.

My submission

It gives a WA on test 7, saying that my code prints ":". But, I am not printing ":" anywhere in my code.

Any help would be really appreciated.

Теги dfs
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

You are appending ch to s and the max value of ch is '1'+k-1 :/
In the given test case the value of k is 1000000000. So....adding that value to '1' will give unexpected results. Remember '1' is not a number, its a char with ASCII value 49. So, you are getting something with ASCII value 1000000049. Since, char has lesser memory, it just cycles and stops at 58, which is ":"