結果
問題 | No.1974 2x2 Flipper |
ユーザー |
![]() |
提出日時 | 2022-06-10 21:30:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 738 bytes |
コンパイル時間 | 1,822 ms |
コンパイル使用メモリ | 173,088 KB |
実行使用メモリ | 7,424 KB |
最終ジャッジ日時 | 2024-09-21 07:04:39 |
合計ジャッジ時間 | 4,589 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
#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; } }