RithwikG's picture
initial commit
7a8878c
raw
history blame contribute delete
775 Bytes
This temple only magnifies the mountain's power.BadelineThis is an interactive problem.You are given two positive integers n and m (n≤m).The jury has hidden from you a rectangular matrix a with n rows and m columns, where ai,j∈{−1,0,1} for all 1≤i≤n and 1≤j≤m. The jury has also selected a cell (i0,j0). Your goal is to find (i0,j0).In one query, you give a cell (i,j), then the jury will reply with an integer. If (i,j)=(i0,j0), the jury will reply with 0. Else, let S be the sum of ax,y over all x and y such that min(i,i0)≤x≤max(i,i0) and min(j,j0)≤y≤max(j,j0). Then, the jury will reply with |i−i0|+|j−j0|+|S|. Find (i0,j0) by making at most n+225 queries.Note: the grader is not adaptive: a and (i0,j0) are fixed before any queries are made.