/* -*- coding: utf-8 -*- * * 1974.cc: No.1974 2x2 Flipper - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_H = 1000; const int MAX_W = 1000; /* typedef */ /* global variables */ int as[MAX_H][MAX_W]; /* subroutines */ void printans(int h, int w, int c) { printf("%d\n", c); for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) printf("%d%c", as[i][j], (j + 1 < w) ? ' ' : '\n'); } /* main */ int main() { int h, w; scanf("%d%d", &h, &w); int he = h & ~1, we = w & ~1; int c = 0; for (int i = 0; i < he; i++) for (int j = 0; j < we; j++) as[i][j] = 1, c++; if (h > 1 && w > 1 && (h & w & 1)) { as[h - 2][w - 2] = 0; as[h - 2][w - 1] = 1; as[h - 1][w - 2] = 1; as[h - 1][w - 1] = 1; c += 2; } printans(h, w, c); return 0; }