skpro19's blog

By skpro19, history, 7 years ago, In English

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.

Tags dfs
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +1 Vote: I do not like it

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 ":"