Let $n\ge 3$ be a positive integer. Amy wrote all the integers from $1$ to $n^2$ on the $n\times n$ grid, so that each cell contains exactly one number. For $i=1,2,\cdots ,n^2-1$, the cell containing $i$ shares a common side with the cell containing $i+1$. Each turn, Bred can choose one cell, and check what number is written. Bred wants to know where $1$ is written by less than $3n$ turns. Determine whether $n$ such that Bred can always achieve his goal is infinite.
Problem
Source: 2022 Korea Winter Program Practice Test
Tags: combinatorics, grids
CANBANKAN
15.08.2022 04:01
I claim all $n=2^k-1$ works. The base case, $k=1$, is clear. Let $f(n)$ be the minimum number of steps for $n$. It suffices to show $f(2n+1)\le f(n)+3(n+1)$.
Label the grid $(i,j)$ where $0\le i,j\le 2n$. Let $f(i,j)$ be the number written on row $i$ and col $j$. Bert first asks $f(n,j)$ for $0\le j\le 2n$. Let $k$ be the index that satisfies the number on $f(n,k)=\min_{0\le j\le 2n} f(n,j)$, then check whether $f(n-1,k)<f(n,k)$. Assume $1$ is not on row $n$, or we are done.
If $f(n-1,k)<f(n,k)$ then $1$ must lie between rows $0$ to $n-1$. This is because if I have a process of filling the numbers in increasing order, the set of squares with a number filled is continuous by the problem condition. It crosses row $n$ at the first time when filling $f(n,k)$, and it goes from $(n+1,k)$ or $(n-1,k)$ to $(n,k)$.
WLOG $f(n-1,k)<f(n,k)$. Now check $f(0,n), \cdots, f(n-1,n)$. If $f(j,n) > f(n-1,k)$ for all $0\le j\le n-1$ then $1$ is in the square $(i,j)_{0\le i,j\le n-1}$. Otherwise, if $j$ satisfies $f(j,n)=\min_{0\le t\le n-1} f(t,n)$ then check $f(j,n-1)$. We can reduce the problem from $(2n+1)\times (2n+1)$ to $n\times n$ in $2n+1 + 1 + n + 1 = 3n+3$ moves. The conclusion follows.
(1) It is a lot harder to prove if the answer is no compared to the answer being yes.
(2) Filling up the grid in increasing order and D&C are standard ideas.
(3) This basically asks for a better algorithm for CAMO 22/4
invt
23.08.2022 18:25
CANBANKAN wrote:
I claim all $n=2^k-1$ works. The base case, $k=1$, is clear. Let $f(n)$ be the minimum number of steps for $n$. It suffices to show $f(2n+1)\le f(n)+3(n+1)$.
Label the grid $(i,j)$ where $0\le i,j\le 2n$. Let $f(i,j)$ be the number written on row $i$ and col $j$. Bert first asks $f(n,j)$ for $0\le j\le 2n$. Let $k$ be the index that satisfies the number on $f(n,k)=\min_{0\le j\le 2n} f(n,j)$, then check whether $f(n-1,k)<f(n,k)$. Assume $1$ is not on row $n$, or we are done.
If $f(n-1,k)<f(n,k)$ then $1$ must lie between rows $0$ to $n-1$. This is because if I have a process of filling the numbers in increasing order, the set of squares with a number filled is continuous by the problem condition. It crosses row $n$ at the first time when filling $f(n,k)$, and it goes from $(n+1,k)$ or $(n-1,k)$ to $(n,k)$.
WLOG $f(n-1,k)<f(n,k)$. Now check $f(0,n), \cdots, f(n-1,n)$. If $f(j,n) > f(n-1,k)$ for all $0\le j\le n-1$ then $1$ is in the square $(i,j)_{0\le i,j\le n-1}$. Otherwise, if $j$ satisfies $f(j,n)=\min_{0\le t\le n-1} f(t,n)$ then check $f(j,n-1)$. We can reduce the problem from $(2n+1)\times (2n+1)$ to $n\times n$ in $2n+1 + 1 + n + 1 = 3n+3$ moves. The conclusion follows.
(1) It is a lot harder to prove if the answer is no compared to the answer being yes.
(2) Filling up the grid in increasing order and D&C are standard ideas.
(3) This basically asks for an optimal algorithm for CAMO 22/4
How can this solution show when the answer is no also what does D&C mean?
CANBANKAN
25.08.2022 03:52
D&C means divide and conquer. The solution shows the answer is yes for infinitely many $n$ and that's what the question asks for (I think I did $3n-2$). This solution doesn't show when the answer is no, and I think that is a very, very challenging problem.
brokendiamond
25.08.2022 22:32
nice solution for this