結果
| 問題 |
No.1851 Regular Tiling
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-02-25 21:51:52 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 2,000 ms |
| コード長 | 1,278 bytes |
| コンパイル時間 | 784 ms |
| コンパイル使用メモリ | 30,080 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 16:39:41 |
| 合計ジャッジ時間 | 2,563 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
ソースコード
#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;
}