結果

問題 No.1851 Regular Tiling
ユーザー 1white_princess1white_princess
提出日時 2022-02-25 22:24:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,116 bytes
コンパイル時間 1,526 ms
コンパイル使用メモリ 168,404 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-16 17:28:33
合計ジャッジ時間 4,712 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,a,b) for(LL i = a;i<b; i++)
#define rrep(i,a,b) for(LL i = a;i>b; i--)
#define tobirep(i,a,b,c) for(LL i = a;i<b; i+=c)
#define tobirrep(i,a,b,c) for(LL i = a;i>b; i-=c)
#define INF ((1LL<<62)-(1LL<<31))
#define ooki 9223372036854775807
#define tii -9223372036854775808
typedef long long LL;
int main(){
   ios::sync_with_stdio(0);cin.tie(nullptr);
   LL t;
  cin >> t;
  rep(i,0,t){
    LL h,w;
    cin >> h >> w;
    LL ans[h][w];
    if(h%2==0&&w%2==0){cout<<-1<<endl;}
   ////////////////////////
    else if(h%2==1&&w%2==0){
       rep(j,0,h){
        rep(k,0,w){
         if(j%2==0||k==0||k==w-1){ans[j][k]=2;}
          else {
            if(ans[j][k-1]==2){ans[j][k]=0;}
            if(ans[j][k-1]==0){ans[j][k]=1;}             
            if(ans[j][k-1]==1&&ans[j][k-2]==1){ans[j][k]=0;}
            if(ans[j][k-1]==1&&ans[j][k-2]==0){ans[j][k]=1;}
          }
        }
       }
    }
    
  
  //////////////////////////
    else if(h%2==0&&w%2==1){
       rep(j,0,h){
        rep(k,0,w){
         if(k%2==0||j==0||j==h-1){ans[j][k]=2;}
          else {
            if(ans[j-1][k]==2){ans[j][k]=1;}
            if(ans[j][k-1]==0){ans[j][k]=1;}
            if(ans[j][k-1]==1&&ans[j][k-2]==1){ans[j][k]=0;}
            if(ans[j][k-1]==1&&ans[j][k-2]==0){ans[j][k]=1;}
          }
        }
       }
    }
  //////////////////////////
    else if(h%2==1&&w%2==1){
       rep(j,0,h){
        rep(k,0,w){
         if(j%2==0||k==0||k==w-1){ans[j][k]=2;}
          else {
            if(ans[j][k-1]==2){ans[j][k]=0;}
            if(ans[j][k-1]==0){ans[j][k]=1;}
            if(ans[j][k-1]==1&&ans[j][k-2]==1){ans[j][k]=0;}
            if(ans[j][k-1]==1&&ans[j][k-2]==0){ans[j][k]=1;}
          }
        }
       }
    }
    //出力
    rep(i,0,h){
      rep(j,0,w){
        cout<<ans[i][j]<<" ";
      }
      cout<<'\n';
    }
    
  }
}
  
  
  
  
  

       
  
  
      


       
  
  
      

0