結果

問題 No.1974 2x2 Flipper
ユーザー SSRS
提出日時 2022-06-10 21:27:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 706 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 172,708 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-09-21 05:58:14
合計ジャッジ時間 5,829 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 21 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W, 0));
  int ans = 0;
  for (int i = 0; i < H - 1; i += 2){
    for (int j = 0; j < W - 1; j += 2){
      A[i][j] = 1;
      A[i][j + 1] = 1;
      A[i + 1][j] = 1;
      A[i + 1][j + 1] = 1;
      ans += 4;
    }
  }
  if (H >= 3 && W >= 3 && H % 2 == 1 && W % 2 == 1){
    A[H - 2][W - 2] = 0;
    A[H - 1][W - 2] = 1;
    A[H - 2][W - 1] = 1;
    A[H - 1][W - 1] = 1;
    ans += 2;
  }
  cout << ans << endl;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cout << A[i][j];
      if (j < W - 1){
        cout << ' ';
      }
    }
    cout << endl;
  }
}
0