結果

問題 No.1851 Regular Tiling
ユーザー kai4096_donkai4096_don
提出日時 2022-02-25 21:44:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,168 bytes
コンパイル時間 3,810 ms
コンパイル使用メモリ 229,436 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 16:28:17
合計ジャッジ時間 6,123 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 28 ms
4,376 KB
testcase_02 AC 33 ms
4,380 KB
testcase_03 AC 32 ms
4,376 KB
testcase_04 AC 29 ms
4,380 KB
testcase_05 AC 31 ms
4,380 KB
testcase_06 AC 35 ms
4,376 KB
testcase_07 AC 29 ms
4,376 KB
testcase_08 AC 30 ms
4,380 KB
testcase_09 AC 34 ms
4,380 KB
testcase_10 AC 31 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 58 ms
4,380 KB
testcase_14 AC 101 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//const long nPrime = 1000000007;
//const long nPrime = 998244353;
typedef long long ll;
int main() {
    long t;
    cin >> t;
    while(t--){
        long h,w;
        cin >> h >> w;
        long h1 = ((h+1)/3)*3+1;
        long w1 = ((w+1)/3)*3+1;
        vector<vector<long>> vviAns(h1,vector<long>(w1,0));
        for(long i = 0; i < h1; i++){
            for(long j = 0; j < w1; j++){
                if(i%3 != 0){
                    vviAns[i][j]++;
                }
                if(j%3 != 0){
                    vviAns[i][j]++;
                }
            }
        }
        long hBeg = 0, hEnd = h1, wBeg = 0, wEnd = w1;
        
        if(h%3==0 || h%3==2){
            hEnd--;
        }
        if(h%3==2){
            hBeg++;
        }
        if(w%3==0 || w%3==2){
            wEnd--;
        }
        if(w%3==2){
            wBeg++;
        }

        for(long i = hBeg; i < hEnd; i++){
            for(long j = wBeg; j < wEnd; j++){
                cout << vviAns[i][j] << " ";
            }
            cout << endl;
        }
    }
    return 0;
}
0