結果

問題 No.1851 Regular Tiling
ユーザー tnakao0123tnakao0123
提出日時 2022-02-25 22:13:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 638 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 41,328 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 17:11:41
合計ジャッジ時間 2,619 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 21 ms
4,380 KB
testcase_02 AC 25 ms
4,376 KB
testcase_03 AC 25 ms
4,376 KB
testcase_04 AC 23 ms
4,380 KB
testcase_05 AC 23 ms
4,376 KB
testcase_06 AC 28 ms
4,380 KB
testcase_07 AC 22 ms
4,380 KB
testcase_08 AC 23 ms
4,380 KB
testcase_09 AC 27 ms
4,380 KB
testcase_10 AC 25 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 45 ms
4,380 KB
testcase_14 AC 88 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1851.cc:  No.1851 Regular Tiling - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

inline int cell(int y, int x) {
  return (y % 3 > 0 ? 1 : 0) + (x % 3 > 0 ? 1 : 0);
}

/* subroutines */

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    int h, w;
    scanf("%d%d", &h, &w);

    int y0 = (h % 3 == 2) ? 1 : 0;
    int x0 = (w % 3 == 2) ? 1 : 0;

    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++)
	printf("%d%c", cell(y + y0, x + x0), (x + 1 < w) ? ' ' : '\n');
  }
  return 0;
}
0