結果

問題 No.2112 All 2x2 are Equal
ユーザー risujiroh
提出日時 2022-10-28 22:19:01
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 2,784 ms
コンパイル使用メモリ 245,344 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-06 01:29:25
合計ジャッジ時間 6,947 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

void solve(std::istream& is, std::ostream& os) {
  int H, W;
  is >> H >> W;
  os << "Yes\n";
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      int x = i * W + j;
      os << ((i + j) & 1
                 ? H * W - x + ((H ^ W) & 1) - 2 * (H & 1 && ~W & 1 && i & 1)
                 : x + 1)
         << " \n"[j + 1 == W];
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  solve(std::cin, std::cout);
}
0