TITLE: Coloring grid points with two colors
QUESTION [6 upvotes]: Let $S$ be a set of finite many grid points (points in the coordinate system with integer coordinates).
Is it always possible to color them with two colors, red and blue, such that in each vertical and horizontal line the following statements is true:
if there are $R$ number of red and $B$ number of blue points, than $|R-B|\leq 1$?

This is an olympiad combinatorics problem (from 1986), but I still can’t solve it. I tried to find strategies to color them, but now I am not even sure that the statement is true.

REPLY [2 votes]: Let $V=\{v_1,v_2,...v_n\}$ be a set of vertical and $H=\{h_1,h_2,...h_m\}$ set of horizontal lines which have vertices from the set $S$ and connect line $v_i$ with line $h_j$ iff $v_i\cap h_j \in S$, so we get a bipartite graph $G= (V,H)$.

So the edges of this graph $G$ are vertices of $S$ (and vertices in $G$ are lines in $V$ and $H$).
It is enough to prove the statement for connected components of $G$.

So let $K$ be any component in $G$ and we procede with induction on $|G|$.
Take any cycle $C$ in $K$ and color it edges alternatively red and blue. Since $G$ has only even cycles this means that each vertex in this cycle $C$ has one red and one blue edge. So if we "delete" all edges of $C$ in $K$ we get $K'$ and we can apply induction on $K'$ and we are done.
Now if there is no cycle in $K$ then $K$ is a tree so we have (at least) two leaves $l,l'$. Take path $P$ from $l$ to $l'$ and color edges again alternatively. Since $l$ and $l'$ have only one edge we are done for them and all other vertices on this path $P$ have again one red and one blue edge. So, if we "delete" all edges on this path we get new $K'$ and we can again use induction on $K'$ and we are done again.