結果

問題 No.1851 Regular Tiling
ユーザー boatmusclesboatmuscles
提出日時 2022-02-25 22:51:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,159 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 32,416 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 18:06:18
合計ジャッジ時間 2,151 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int testcase_i;
    scanf("%d", &testcase_i);
    for (int ___ = 0; ___ < testcase_i; ___++){
        int H, W;
        scanf("%d %d", &H, &W);
        char pattern[3][3];
        if(H%3 == 1){
            if(W%3 == 1){
                char tmp[3][3] = {{'0','1','1'},{'1','2','2'},{'1','2','2'}};
                rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j];
            }else{
                char tmp[3][3] = {{'1','1','0'},{'2','2','1'},{'2','2','1'}};
                rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j];
            }
        }else if(W%3 == 1){
            char tmp[3][3] = {{'1','2','2'},{'1','2','2'},{'0','1','1'}};
            rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j];
        }else{
            char tmp[3][3] = {{'2','2','1'},{'2','2','1'},{'1','1','0'}};
            rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j];
        }
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                printf("%c", pattern[i%3][j%3]);
                printf(j < W-1 ? " " : "\n");
            }
        }
    }
}
0