結果

問題 No.1851 Regular Tiling
ユーザー 👑 ygussanyygussany
提出日時 2022-02-25 21:51:52
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 1,278 bytes
コンパイル時間 539 ms
コンパイル使用メモリ 28,956 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 16:41:31
合計ジャッジ時間 2,523 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 8 ms
4,380 KB
testcase_02 AC 10 ms
4,376 KB
testcase_03 AC 10 ms
4,376 KB
testcase_04 AC 10 ms
4,380 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 11 ms
4,380 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 9 ms
4,376 KB
testcase_09 AC 10 ms
4,376 KB
testcase_10 AC 9 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 17 ms
4,376 KB
testcase_14 AC 34 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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