Update exam/packet.tex
This commit is contained in:
@@ -184,5 +184,56 @@ Output 3:
|
|||||||
EMPTY
|
EMPTY
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
|
% ========================= Problem 7 =========================
|
||||||
|
\problem{Problem 7: Limited Jumps}
|
||||||
|
\textit{Difficulty: Medium}
|
||||||
|
|
||||||
|
You are given a grid of size N x M, where each cell contains either 6 or 7. You start at the top-left corner (1,1) and want to reach the bottom-right corner (N,M). You can move right, down, or jump diagonally (right+down). The maze has these rules:
|
||||||
|
\begin{itemize}
|
||||||
|
\item You can step on a 6 any number of times
|
||||||
|
\item You can step on a 7 at most once in your path
|
||||||
|
\item You can make at most one diagonal move in your path
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
Your task is to determine if there exists any valid path from (1,1) to (N,M) obeying the rules.
|
||||||
|
|
||||||
|
\inputformat
|
||||||
|
\begin{itemize}
|
||||||
|
\item The first line consists 2 integers N and M ($1 \leq N, M \leq 10^9$), the number of rows and columns, respectively
|
||||||
|
\item The next N lines will consist of strings of length M, containing 6 or 7
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\outputformat
|
||||||
|
\begin{itemize}
|
||||||
|
\item Output a single line. If there exists a valid path, print ``Sixxx sevennn" (without the quotations). If there does not exist a valid path, print ``Six was afraid of seven after all" (without the quotations).
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\examples
|
||||||
|
\begin{verbatim}
|
||||||
|
Input 1:
|
||||||
|
2 2
|
||||||
|
66
|
||||||
|
67
|
||||||
|
|
||||||
|
Output 1:
|
||||||
|
Sixxx sevennn
|
||||||
|
|
||||||
|
Input 2:
|
||||||
|
2 2
|
||||||
|
77
|
||||||
|
77
|
||||||
|
|
||||||
|
Output 2:
|
||||||
|
Six was afraid of seven after all
|
||||||
|
|
||||||
|
Input 3:
|
||||||
|
3 3
|
||||||
|
666
|
||||||
|
676
|
||||||
|
666
|
||||||
|
|
||||||
|
Output 3:
|
||||||
|
Sixxx sevennn
|
||||||
|
\end{verbatim}
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user