結果

問題 No.1974 2x2 Flipper
ユーザー umezoumezo
提出日時 2022-06-10 23:03:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 2,822 ms
コンパイル使用メモリ 204,812 KB
実行使用メモリ 7,588 KB
最終ジャッジ日時 2023-10-21 06:01:17
合計ジャッジ時間 6,429 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 11 ms
6,360 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 48 ms
7,404 KB
testcase_04 AC 23 ms
6,360 KB
testcase_05 AC 15 ms
6,360 KB
testcase_06 AC 35 ms
6,420 KB
testcase_07 AC 24 ms
7,072 KB
testcase_08 AC 7 ms
6,356 KB
testcase_09 AC 36 ms
6,360 KB
testcase_10 AC 6 ms
6,356 KB
testcase_11 AC 28 ms
6,360 KB
testcase_12 AC 47 ms
6,568 KB
testcase_13 AC 30 ms
6,732 KB
testcase_14 AC 19 ms
6,360 KB
testcase_15 AC 55 ms
6,840 KB
testcase_16 AC 7 ms
6,360 KB
testcase_17 AC 40 ms
7,404 KB
testcase_18 AC 6 ms
4,348 KB
testcase_19 AC 7 ms
6,356 KB
testcase_20 AC 23 ms
6,360 KB
testcase_21 AC 72 ms
7,588 KB
testcase_22 AC 71 ms
7,580 KB
testcase_23 AC 72 ms
7,588 KB
testcase_24 AC 72 ms
7,584 KB
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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[1010][1010];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int h,w;
  cin>>h>>w;
  
  if(h%2==0 && w%2==0){
    rep(i,h) rep(j,w) G[i][j]=1;
  }
  else if(h%2==0){
    rep(i,h) rep(j,w-1) G[i][j]=1;
  }
  else if(w%2==0){
    rep(i,h-1) rep(j,w) G[i][j]=1;
  }
  else{
    auto dfs=[&](auto dfs,int x,int y,int rx,int ry){
      if(rx==1 || ry==1) return;
      G[x][y]=1,G[x+1][y+1]=1;
      for(int j=0;j<ry-2;j++){
        G[x][y+2+j]=1;
        G[x+1][y+2+j]=1;
      }
      for(int i=0;i<rx-2;i++){
        G[x+2+i][y]=1;
        G[x+2+i][y+1]=1;
      }
      dfs(dfs,x+2,y+2,rx-2,ry-2);
    };
    dfs(dfs,0,0,h,w);
  }
  
  int ans=0;
  rep(i,h) rep(j,w) if(G[i][j]) ans++;
  cout<<ans<<endl;
  
  rep(i,h){
    rep(j,w){
      if(j) cout<<" ";
      cout<<G[i][j];
    }
    cout<<endl;
  }

  return 0;
}
0