結果

問題 No.1851 Regular Tiling
コンテスト
ユーザー ygussany
提出日時 2022-02-25 21:51:52
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 1,278 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 209 ms
コンパイル使用メモリ 39,372 KB
最終ジャッジ日時 2026-02-22 08:49:37
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

void solve(int H, int W)
{
	int i, j;
	if (H % 3 != 2) {
		if (W % 3 == 1) {
			for (j = 0; j < W; j++) {
				if (j % 3 == 0) printf("0 ");
				else printf("1 ");
			}
			printf("\n");
		} else {
			for (j = 0; j < W; j++) {
				if (j % 3 == 2) printf("0 ");
				else printf("1 ");
			}
			printf("\n");
		}
		i = 1;
	} else i = 0;
	for (; i < H; i++) {
		if (W % 3 == 1) {
			for (j = 0; j < W; j++) {
				if (j % 3 == 0) printf("1 ");
				else printf("2 ");
			}
			printf("\n");
			for (j = 0; j < W; j++) {
				if (j % 3 == 0) printf("1 ");
				else printf("2 ");
			}
			printf("\n");
		} else {
			for (j = 0; j < W; j++) {
				if (j % 3 == 2) printf("1 ");
				else printf("2 ");
			}
			printf("\n");
			for (j = 0; j < W; j++) {
				if (j % 3 == 2) printf("1 ");
				else printf("2 ");
			}
			printf("\n");
		}
		i += 2;
		if (i >= H) break;
		if (W % 3 == 1) {
			for (j = 0; j < W; j++) {
				if (j % 3 == 0) printf("0 ");
				else printf("1 ");
			}
			printf("\n");
		} else {
			for (j = 0; j < W; j++) {
				if (j % 3 == 2) printf("0 ");
				else printf("1 ");
			}
			printf("\n");
		}
	}
}

int main()
{
	int t, T, H, W;
	scanf("%d", &T);
	for (t = 1; t <= T; t++) {
		scanf("%d %d", &H, &W);
		solve(H, W);
	}
	fflush(stdout);
	return 0;
}
0