結果
| 問題 | No.2112 All 2x2 are Equal | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2022-11-01 20:09:02 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 889 bytes | 
| コンパイル時間 | 262 ms | 
| コンパイル使用メモリ | 42,720 KB | 
| 実行使用メモリ | 7,012 KB | 
| 最終ジャッジ日時 | 2024-07-16 09:48:12 | 
| 合計ジャッジ時間 | 6,969 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 23 WA * 11 | 
ソースコード
/* -*- coding: utf-8 -*-
 *
 * 2112.cc:  No.2112 All 2x2 are Equal - yukicoder
 */
#include<cstdio>
#include<algorithm>
 
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);
  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]);
  }
  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;
}
            
            
            
        