\documentclass[11pt]{scrartcl}
\usepackage{evan}
\begin{document}
\title{PAGMO 2022/1}
\subtitle{Evan Chen}
\author{Twitch Solves ISL}
\date{Episode 108}
\maketitle
\section*{Problem}
Leticia has a $9\times 9$ toroidal board; each square
thus has four orthogonal neighbors, which we call its \emph{friends}.
Leticia will paint every square one of three colors: green, blue or red.
Then in each square we write a number as follows:
\begin{itemize}
\ii If the square is green, write the number of red friends
plus twice the number of blue friends.
\ii If the square is red, write the number of blue friends
plus twice the number of green friends.
\ii If the square is blue, write the number of green friends
plus twice the number of red friends.
\end{itemize}
Considering that Leticia can choose the coloring of the squares on the board,
find the maximum possible value she can obtain
when she sums the numbers in all the squares.
\section*{Video}
\href{https://www.youtube.com/watch?v=C9WhZldyMuc&t=185s}{\texttt{https://youtu.be/C9WhZldyMuc}}
\section*{External Link}
\url{https://aops.com/community/p26404362}
\newpage
\section*{Solution}
The answer is $3 \cdot 162 = 486$.
The ``maximality'' is mostly a red herring due to the following claim:
\begin{claim*}
The sum in question is equal to $3$ times the number of neighboring
cells which are different colors.
\end{claim*}
\begin{proof}
If $s$ and $t$ are different colors, one of them gets counted as $+2$
and the other as $+1$. No contribution if they're the same color.
\end{proof}
As there are $162$ pairs of neighboring cells, the bound of $486$ follows.
Equality occurs in any coloring with no adjacent cells of the same
color, e.g.\ $x+y \bmod 3$.
\end{document}