Problem

Source: Pan-American Girls' Mathematical Olympiad 2022, Problem 1

Tags: combinatorics, grids, PAGMO, Colors



Leticia has a $9\times 9$ board. She says that two squares are friends is they share a side, if they are at opposite ends of the same row or if they are at opposite ends of the same column. Every square has $4$ friends on the board. Leticia will paint every square one of three colors: green, blue or red. In each square a number will be written based on the following rules: - If the square is green, write the number of red friends plus twice the number of blue friends. - If the square is red, write the number of blue friends plus twice the number of green friends. - If the square is blue, write the number of green friends plus twice the number of red friends. 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.