結果
問題 | No.1974 2x2 Flipper |
ユーザー |
![]() |
提出日時 | 2022-06-11 03:39:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 1,579 bytes |
コンパイル時間 | 1,685 ms |
コンパイル使用メモリ | 168,372 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 11:03:14 |
合計ジャッジ時間 | 5,453 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2022.06.11 03:39:21 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int h,w;cin >> h >> w; if (h%2==0&&w%2==0) { cout << h*w << endl; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cout << 1 << " "; } cout << endl; } } else if (h%2==0) { cout << h*(w-1) << endl; for (int i = 0; i < h; i++) { for (int j = 0; j < w-1; j++) { cout << 1 << " "; } cout << 0 << endl; } } else if (w%2 == 0) { cout << (h-1)*w << endl; for (int i = 0; i < h-1; i++) { for (int j = 0; j < w; j++) { cout << 1 << " "; } cout << endl; } for (int j = 0; j < w; j++) { cout << 0 << " "; } cout << endl; } else if (h < w) { cout << h*w-w << endl; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (i==j||(i==0&&h<=j)) cout << 0 << " "; else cout << 1 << " "; } cout << endl; } } else { cout << h*w-h << endl; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (i==j||(j==0&&w<=i)) cout << 0 << " "; else cout << 1 << " "; } cout << endl; } } return 0; }