結果

問題 No.1851 Regular Tiling
ユーザー 蜜蜂蜜蜂
提出日時 2021-03-23 14:42:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,139 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 170,052 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 15:10:10
合計ジャッジ時間 3,730 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 23 ms
4,376 KB
testcase_02 AC 27 ms
4,376 KB
testcase_03 AC 26 ms
4,380 KB
testcase_04 AC 24 ms
4,376 KB
testcase_05 AC 25 ms
4,376 KB
testcase_06 AC 28 ms
4,376 KB
testcase_07 AC 25 ms
4,376 KB
testcase_08 AC 25 ms
4,380 KB
testcase_09 AC 29 ms
4,380 KB
testcase_10 AC 26 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 48 ms
4,376 KB
testcase_14 AC 79 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vld = vector<ld>;
using vvld = vector<vld>;

#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define rep(i,start,end) for(ll i=start;i<(ll)(end);i++)
#define per(i,start,end) for(ll i=start;i>=(ll)(end);i--)

void solve(){
  int h,w;
  cin>>h>>w;

  int x=((h+2)/3)*3,y=((w+2)/3)*3;

  vvi ans(x,vi(y));
  rep(i,0,x){
    rep(j,0,y){
      if(i%3==0&&j%3==0){
        ans[i][j]=0;
      }
      else if(i%3>=1&&j%3>=1){
        ans[i][j]=2;
      }
      else{
        ans[i][j]=1;
      }
    }
  }

  int start_x=0,end_x=x,start_y=0,end_y=y;

  if(h%3==1){
    end_x-=2;
  }
  if(h%3==2){
    start_x++;
  }

  if(w%3==1){
    end_y-=2;
  }
  if(w%3==2){
    start_y++;
  }

  rep(i,start_x,end_x){
    rep(j,start_y,end_y){
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int t;
  cin>>t;

  while(t--){
    solve();
  }
}
0