From 929a60898caa5213106430bcfc0401cab3c9d9f0 Mon Sep 17 00:00:00 2001 From: problsolv Date: Sat, 22 Nov 2025 22:41:59 -0600 Subject: [PATCH] Update exam/packet.tex --- exam/packet.tex | 70 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/exam/packet.tex b/exam/packet.tex index c141eee..b519ec9 100644 --- a/exam/packet.tex +++ b/exam/packet.tex @@ -6,7 +6,7 @@ \usepackage{listings} \usepackage{xcolor} \usepackage{enumitem} -\usepackage{comment} + % Page layout \geometry{margin=1in} \pagestyle{fancy} @@ -54,7 +54,7 @@ \item For each problem, write a function or program according to the specified input/output format. \item Clearly comment your code if necessary. \end{enumerate} -\begin{comment} + % ========================= Problem 1 ========================= \problem{Problem 1: Two Sum} \textit{Difficulty: Easy} @@ -140,13 +140,13 @@ Output: 8 10 15 18 \end{verbatim} -\end{comment} -% ========================= Problem 6 ========================= -\problem{Problem 6(.7): Six Seven} -\textit{Difficulty: Easy} -\begin{itemize} -You are given a string S composed of only the characters ‘6', ‘7’, ‘A', ‘B', and ‘\#' (without the quotation marks). This string is processed from left to right, and you must maintain a sequence of chracters that changes according to these rules: +% ========================= Problem 4 ========================= +\problem{Problem 4: Six Seven} +\textit{Difficulty: Easy} + +You are given a string S composed of only the characters ‘6', ‘7’, ‘A', ‘B', and ‘\#' (without the quotation marks). This string is processed from left to right, and you must maintain a sequence of chracters that changes according to these rules: +\begin{itemize} \item 6 - add a 6 to the end of the sequence \item 7 - if the sequence is non-empty and its last chracter is ‘6', remove that last ‘6', otherwise, add ‘7' to the end of the sequence \item A - reverse the sequence @@ -155,7 +155,7 @@ You are given a string S composed of only the characters ‘6', ‘7’, ‘A', \end{itemize} \inputformat \begin{itemize} - \item The first line consists of the string S. The string consists only of the characters 6, 7, A, B, and \#. + \item The first line consists of the string S ($1 \leq |S| \leq 2 * 10^5$). The string consists only of the characters 6, 7, A, B, and \#. \end{itemize} \outputformat @@ -184,5 +184,55 @@ Output 3: EMPTY \end{verbatim} -\end{document} +% ========================= Problem 5 ========================= +\problem{Problem 5: 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} \ No newline at end of file