結果

問題 No.1851 Regular Tiling
ユーザー umezoumezo
提出日時 2022-02-25 23:31:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 1,289 bytes
コンパイル時間 1,894 ms
コンパイル使用メモリ 200,828 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 19:03:49
合計ジャッジ時間 4,124 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 24 ms
4,380 KB
testcase_02 AC 30 ms
4,376 KB
testcase_03 AC 30 ms
4,380 KB
testcase_04 AC 27 ms
4,380 KB
testcase_05 AC 28 ms
4,376 KB
testcase_06 AC 31 ms
4,380 KB
testcase_07 AC 26 ms
4,376 KB
testcase_08 AC 27 ms
4,380 KB
testcase_09 AC 31 ms
4,376 KB
testcase_10 AC 28 ms
4,380 KB
testcase_11 AC 3 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 49 ms
4,376 KB
testcase_14 AC 88 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:62:24: 警告: ‘nj’ may be used uninitialized [-Wmaybe-uninitialized]
   62 |       for(int j=nj;j<nj+w;j++){
      |                      ~~^~
main.cpp:38:12: 備考: ‘nj’ はここで定義されています
   38 |     int ni,nj;
      |            ^~
main.cpp:38:9: 警告: ‘ni’ may be used uninitialized [-Wmaybe-uninitialized]
   38 |     int ni,nj;
      |         ^~

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

int G[200][200];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool f(int x,int y,int lh,int lw,int rh,int rw){
  int cnt=0;
  rep(i,4){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<lh || ny<lw || nx>=rh || ny>=rw) continue;
    if(G[nx][ny]==G[x][y]) cnt++;
  }
  if(G[x][y]==cnt) return true;
  else return false;
}
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  rep(i,200) rep(j,200){
    if(i%3==0 && j%3!=0) G[i][j]=1;
    else if(j%3==0 && i%3!=0) G[i][j]=1;
    else if(i%3!=0 && j%3!=0) G[i][j]=2;
  }
  
  int t;
  cin>>t;
  while(t--){
    int h,w;
    cin>>h>>w;
    int ni,nj;
    
    rep(i,3){
      bool b=true;
      rep(j,3){
        b=true;
        rep(x,h){
          rep(y,w){
            if(f(i+x,j+y,i,j,i+h,j+w)==false){
              b=false;
              break;
            }
          }
          if(b==false) break;
        }
        if(b){
          ni=i,nj=j;
          break;
        }
      }
      if(b) break;
    }
    
    for(int i=ni;i<ni+h;i++){
      for(int j=nj;j<nj+w;j++){
        if(j) cout<<" ";
        cout<<G[i][j];
      }
      cout<<endl;
    }
  }
   
  return 0;
}
0