Question: PhonePe , Recent Online Assessment Questions | PhonePe Fun Day | Shortest God String | Hidden Cave Treasure Hunt | Inquisitive Romio | 11th August 2023
4
Entering edit mode

ADD COMMENTlink 16 months ago PoGo 2.4k
0
Entering edit mode

Question 1 Fun Day
from collections import deque

n=int(input())

x,y=list(map(int,input().split()))

k=int(input())

n-=1

q=deque()

q.append((x-1,y-1,k))

won=lost=0

while q:

x,y,k=q.popleft()

if 0<=x<=n and 0<=y<=n:

if k==0:

won+=1

else:

q.append((x-1,y,k-1))

q.append((x,y-1,k-1))

q.append((x+1,y,k-1))

q.append((x,y+1,k-1))

else:

lost+=1

print(won/(won+lost))

 

ADD COMMENTlink 5 months ago siister • 0

Login before adding your answer.

Similar Posts
Loading Similar Posts