/* * Sample solution to the Billboard problem. * Central Europe Regional Contest 2007. * * Martin Kacer, 2007 */ import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class billboard { public static final int MAX = 24 + 2; // add two for "border" tiles public static final char CH_BLACK = 'X'; private static final int INF = MAX*MAX; int x, y; int mask; int board[] = new int[MAX]; // initial board int work[] = new int[MAX]; // working copy int cnt; void togglebits(int row, int bits) { for (int b = 2; (b & mask) == b; b<<=1) { if ((bits & b) != 0) ++cnt; } work[row-1] ^= bits; work[row] ^= (bits ^ (bits<<1) ^ (bits>>1)); work[row+1] ^= bits; } void run() throws Exception { for (;;) { x = nextInt(); y = nextInt(); if (x*y == 0) break; mask = (~(-1<