結果

問題 No.1974 2x2 Flipper
ユーザー SSRSSSRS
提出日時 2022-06-10 21:30:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 172,572 KB
実行使用メモリ 7,616 KB
最終ジャッジ日時 2023-10-21 05:54:52
合計ジャッジ時間 5,029 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 10 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 49 ms
6,268 KB
testcase_04 AC 23 ms
4,840 KB
testcase_05 AC 14 ms
4,348 KB
testcase_06 AC 35 ms
5,500 KB
testcase_07 AC 24 ms
4,844 KB
testcase_08 AC 7 ms
4,348 KB
testcase_09 AC 36 ms
5,596 KB
testcase_10 AC 6 ms
4,348 KB
testcase_11 AC 28 ms
5,140 KB
testcase_12 AC 48 ms
6,260 KB
testcase_13 AC 30 ms
5,228 KB
testcase_14 AC 19 ms
4,592 KB
testcase_15 AC 56 ms
6,688 KB
testcase_16 AC 7 ms
4,348 KB
testcase_17 AC 40 ms
5,808 KB
testcase_18 AC 7 ms
4,348 KB
testcase_19 AC 7 ms
4,348 KB
testcase_20 AC 22 ms
4,808 KB
testcase_21 AC 72 ms
7,616 KB
testcase_22 AC 72 ms
7,608 KB
testcase_23 AC 72 ms
7,616 KB
testcase_24 AC 72 ms
7,612 KB
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W, 1));
  if (H % 2 == 1 && W % 2 == 0){
    A[H - 1] = vector<int>(W, 0);
  } else if (H % 2 == 0 && W % 2 == 1){
    for (int i = 0; i < H; i++){
      A[i][W - 1] = 0;
    }
  } else if (H % 2 == 1 && W % 2 == 1){
    for (int i = 0; i < max(H, W); i++){
      A[min(i, H - 1)][min(i, W - 1)] = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      ans += A[i][j];
    }
  }
  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