Have a look at my code

I am getting WA https://ide.codingblocks.com/s/288100

hello @sshreya2912
ur logic was correct.
but u were not printing it correctly.

this is correct code for printing distances
image

check ur updated code here