結果

問題 No.1851 Regular Tiling
ユーザー ripityripity
提出日時 2022-02-25 21:55:48
言語 Java19
(openjdk 21)
結果
AC  
実行時間 503 ms / 2,000 ms
コード長 1,389 bytes
コンパイル時間 2,336 ms
コンパイル使用メモリ 76,248 KB
実行使用メモリ 62,404 KB
最終ジャッジ日時 2023-09-16 16:48:42
合計ジャッジ時間 9,472 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
55,924 KB
testcase_01 AC 343 ms
59,800 KB
testcase_02 AC 387 ms
61,420 KB
testcase_03 AC 372 ms
61,400 KB
testcase_04 AC 366 ms
60,520 KB
testcase_05 AC 372 ms
60,340 KB
testcase_06 AC 395 ms
60,876 KB
testcase_07 AC 369 ms
60,368 KB
testcase_08 AC 371 ms
60,052 KB
testcase_09 AC 364 ms
61,508 KB
testcase_10 AC 391 ms
59,516 KB
testcase_11 AC 173 ms
56,336 KB
testcase_12 AC 176 ms
56,044 KB
testcase_13 AC 481 ms
62,404 KB
testcase_14 AC 503 ms
60,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    
    public static Scanner sc = new Scanner(System.in);
    public static PrintWriter pw = new PrintWriter(System.out);
    
    public static void main(String[] args) {
        
        int t = sc.nextInt();
        while( t > 0 ) {
            solve();
            t--;
        }
        
        pw.flush();
        
    }
    
    static void solve() {
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        if( H == 1 ) {
            int[] g = {1,1,0};
            int id = W%3 == 1 ? 2 : 0;
            for( int i = 0; i < W; i++ ) {
                pw.print(g[(id+i)%3]+" ");
            }
            pw.println();
        }else if( W == 1 ) {
            int[] g = {1,1,0};
            int id = H%3 == 1 ? 2 : 0;
            for( int i = 0; i < H; i++ ) {
                pw.println(g[(id+i)%3]);
            }
        }else {
            int[][] g = {
                {2,2,1},
                {2,2,1},
                {1,1,0}
            };
            int idi = H%3 == 1 ? 2 : 0;
            int idj = W%3 == 1 ? 2 : 0;
            for( int i = 0; i < H; i++ ) {
                for( int j = 0; j < W; j++ ) {
                    pw.print(g[(idi+i)%3][(idj+j)%3]+" ");
                }
                pw.println();
            }
        }
        
        pw.println();
        
    }
    
}
0