結果

問題 No.2112 All 2x2 are Equal
ユーザー 👑 chro_96chro_96
提出日時 2022-10-28 22:23:24
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 1,001 bytes
コンパイル時間 1,851 ms
コンパイル使用メモリ 29,988 KB
実行使用メモリ 5,748 KB
最終ジャッジ日時 2023-09-20 05:26:23
合計ジャッジ時間 6,409 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,716 KB
testcase_01 AC 2 ms
5,744 KB
testcase_02 AC 5 ms
5,740 KB
testcase_03 AC 4 ms
5,724 KB
testcase_04 AC 39 ms
5,684 KB
testcase_05 AC 48 ms
5,716 KB
testcase_06 AC 83 ms
5,724 KB
testcase_07 AC 27 ms
5,736 KB
testcase_08 AC 67 ms
5,736 KB
testcase_09 AC 6 ms
5,720 KB
testcase_10 AC 32 ms
5,716 KB
testcase_11 AC 22 ms
5,740 KB
testcase_12 AC 26 ms
5,736 KB
testcase_13 AC 73 ms
5,676 KB
testcase_14 AC 6 ms
5,652 KB
testcase_15 AC 55 ms
5,736 KB
testcase_16 AC 2 ms
5,748 KB
testcase_17 AC 66 ms
5,588 KB
testcase_18 AC 4 ms
5,720 KB
testcase_19 AC 7 ms
5,716 KB
testcase_20 AC 4 ms
5,728 KB
testcase_21 AC 65 ms
5,732 KB
testcase_22 AC 6 ms
5,620 KB
testcase_23 AC 5 ms
5,724 KB
testcase_24 AC 9 ms
5,592 KB
testcase_25 AC 12 ms
5,720 KB
testcase_26 AC 10 ms
5,716 KB
testcase_27 AC 17 ms
5,624 KB
testcase_28 AC 40 ms
5,624 KB
testcase_29 AC 7 ms
5,728 KB
testcase_30 AC 27 ms
5,728 KB
testcase_31 AC 50 ms
5,732 KB
testcase_32 AC 88 ms
5,692 KB
testcase_33 AC 87 ms
5,736 KB
testcase_34 AC 90 ms
5,620 KB
testcase_35 AC 89 ms
5,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int h = 0;
  int w = 0;
  
  int res = 0;
  
  int t = 0;
  int ans[1000][1000] = {};
  
  res = scanf("%d", &h);
  res = scanf("%d", &w);
  
  if (h%2 == 1 && w%2 == 0) {
    int tmp = h;
    h = w;
    w = tmp;
    t = 1;
  }
  
  for (int i = 0; i < h/2; i++) {
    for (int j = 0; j < w; j++) {
      ans[i*2+j%2][j] = i*w+j+1;
      ans[i*2+1-j%2][j] = h*w-i*w-j;
    }
  }
  
  if (h%2 == 1) {
    for (int j = 0; j < w; j += 2) {
      ans[h-1][j] = w*(h/2)+j+1;
    }
    for (int j = 1; j < w; j += 2) {
      ans[h-1][j] = h*w-w*(h/2)-j;
    }
  }
  
  printf("Yes\n");
  if (t > 0) {
    for (int i = 0; i < w; i++) {
      printf("%d", ans[0][i]);
      for (int j = 1; j < h; j++) {
        printf(" %d", ans[j][i]);
      }
      printf("\n");
    }
  } else {
    for (int i = 0; i < h; i++) {
      printf("%d", ans[i][0]);
      for (int j = 1; j < w; j++) {
        printf(" %d", ans[i][j]);
      }
      printf("\n");
    }
  }
  
  return 0;
}
0