/* -*- coding: utf-8 -*- * * 2112.cc: No.2112 All 2x2 are Equal - 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 */ /* main */ int main() { int h, w; scanf("%d%d", &h, &w); bool r = false; if ((h & 1) && ! (w & 1)) r = true, swap(h, w); int x = 1, y = h * w; for (int i = 0; i + 1 < h; i += 2) for (int j = 0; j < w; j++) { int p = j & 1; as[i + p][j] = x++, as[i + (p ^ 1)][j] = y--; } if (h & 1) { int s = as[0][0] + as[0][1] + as[1][0] + as[1][1]; as[h - 1][0] = x++; for (int j = 1; j < w; j++) as[h - 1][j] = s - (as[h - 2][j - 1] + as[h - 2][j] + as[h - 1][j - 1]); } if (r) { int l = max(h, w); for (int i = 0; i < l; i++) for (int j = i + 1; j < l; j++) swap(as[i][j], as[j][i]); swap(h, w); } puts("Yes"); for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) printf("%d%c", as[i][j], (j + 1 < w) ? ' ' : '\n'); return 0; }