結果

問題 No.2112 All 2x2 are Equal
ユーザー tnakao0123tnakao0123
提出日時 2022-11-01 20:09:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 889 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 42,068 KB
実行使用メモリ 6,888 KB
最終ジャッジ日時 2023-09-23 10:18:25
合計ジャッジ時間 9,550 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 53 ms
5,096 KB
testcase_06 AC 91 ms
6,728 KB
testcase_07 AC 30 ms
4,380 KB
testcase_08 AC 75 ms
6,868 KB
testcase_09 WA -
testcase_10 AC 35 ms
5,108 KB
testcase_11 AC 24 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 81 ms
6,440 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 72 ms
6,240 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 8 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 10 ms
5,160 KB
testcase_25 AC 14 ms
4,444 KB
testcase_26 AC 10 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 10 ms
6,376 KB
testcase_30 AC 29 ms
4,376 KB
testcase_31 AC 56 ms
6,672 KB
testcase_32 AC 97 ms
6,888 KB
testcase_33 AC 97 ms
6,832 KB
testcase_34 WA -
testcase_35 AC 98 ms
6,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- 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;
}
0