Codejam Qualification Round 2018. Task 3
Python Only
def go_gopher(a):
k=a//3+1
l=k//3
ra=[3*i+2 for i in list(range(l))]
if k-1>ra[-1]:
ra+=[k-1]
c=1000
go_ra=[ra[j%len(ra)] for j in range(c)]
for i in go_ra:
x,y=[i-1,i,i+1],[1,2,3]
xy=[' '.join([str(el) for el in [xy1,xy2]])
for xy1 in x for xy2 in y]
flag=False
while xy!=[]:
out_xy='%d 2'%i
print(out_xy,flush=True)
in_xy=input()
if in_xy in xy:
xy.remove(in_xy)
elif in_xy=='0 0':
flag=True
break
elif in_xy=='-1 -1':
exit()
# print(xy)
if flag==True:
break
T=int(input())
for i in range(T):
A=int(input())
go_gopher(A)