knightnemo commited on
Commit
68be260
·
verified ·
1 Parent(s): 083d7b7

Upload code_segments/segment_123.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_123.txt +31 -0
code_segments/segment_123.txt ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This temple only magnifies the mountain's power.
2
+
3
+ Badeline
4
+
5
+ This is an interactive problem.
6
+
7
+ You are given two positive integers $n$ and $m$ ($\bf{n \le m}$).
8
+
9
+ The jury has hidden from you a rectangular matrix $a$ with $n$ rows and $m$ columns, where $a_{i,j} \in \\{ -1, 0, 1 \\}$ for all $1 \le i \le n$ and $1 \le j \le m$. The jury has also selected a cell $(i_0, j_0)$. Your goal is to find $(i_0,j_0)$.
10
+
11
+ In one query, you give a cell $(i, j)$, then the jury will reply with an integer.
12
+
13
+ * If $(i, j) = (i_0, j_0)$, the jury will reply with $0$. * Else, let $S$ be the sum of $a_{x,y}$ over all $x$ and $y$ such that $\min(i, i_0) \le x \le \max(i, i_0)$ and $\min(j, j_0) \le y \le \max(j, j_0)$. Then, the jury will reply with $|i - i_0| + |j - j_0| + |S|$.
14
+
15
+ Find $(i_0, j_0)$ by making at most $n + 225$ queries.
16
+
17
+ Note: the grader is not adaptive: $a$ and $(i_0,j_0)$ are fixed before any queries are made.
18
+
19
+ Each test contains multiple test cases. The first line of input contains a single integer $t$ ($1 \le t \le 50$) — the number of test cases. The description of the test cases follows.
20
+
21
+ The only line of each test case contains two integers $n$ and $m$ ($1 \le n \le m \le 5000$) — the numbers of rows and the number of columns of the hidden matrix $a$ respectively.
22
+
23
+ It is guaranteed that the sum of $n \cdot m$ over all test cases does not exceed $25 \cdot 10^6$.
24
+
25
+
26
+
27
+ The hidden matrix in the first test case:
28
+
29
+ $1$| $0$| $1$| $\color{red}{\textbf{0}}$ ---|---|---|--- $1$| $0$| $0$| $1$ $0$| $-1$| $-1$| $-1$ The hidden matrix in the second test case:
30
+
31
+ $\color{red}{\textbf{0}}$ --- Note that the line breaks in the example input and output are for the sake of clarity, and do not occur in the real interaction.