結果
問題 |
No.1974 2x2 Flipper
|
ユーザー |
![]() |
提出日時 | 2022-03-28 21:29:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 93 ms / 2,000 ms |
コード長 | 1,817 bytes |
コンパイル時間 | 8,171 ms |
コンパイル使用メモリ | 298,304 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 07:04:51 |
合計ジャッジ時間 | 11,344 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> #include "testlib.h" using namespace std; int main() { registerValidation(); int H, W; H = inf.readInt(1, 1000); inf.readSpace(); W = inf.readInt(1, 1000); inf.readEoln(); inf.readEof(); if (H % 2 == 0 && W % 2 == 0) { cout << H * W << endl; for (int i = 0; i < H; i++) { cout << 1; for (int j = 1; j < W; j++) { cout << " " << 1; } cout << endl; } } if (H % 2 == 1 && W % 2 == 0) { cout << (H - 1) * W << endl; for (int i = 0; i < H - 1; i++) { cout << 1; for (int j = 1; j < W; j++) { cout << " " << 1; } cout << endl; } cout << 0; for (int j = 1; j < W; j++) { cout << " " << 0; } cout << endl; } if (H % 2 == 0 && W % 2 == 1) { cout << H * (W - 1) << endl; for (int i = 0; i < H; i++) { cout << 1; for (int j = 1; j < W - 1; j++) { cout << " " << 1; } cout << " " << 0; cout << endl; } } if (H % 2 == 1 && W % 2 == 1) { if (H >= W) { cout << H * (W - 1) << endl; for (int i = 0; i < W; i++) { if (i != 0) cout << 1; else cout << 0; for (int j = 1; j < W; j++) { if (i != j) cout << " " << 1; else cout << " " << 0; } cout << endl; } for (int i = W; i < H; i++) { if (((i - W) / 2) % W != 0) cout << 1; else cout << 0; for (int j = 1; j < W; j++) { if (((i - W) / 2) % W != j) cout << " " << 1; else cout << " " << 0; } cout << endl; } } else { cout << (H - 1) * W << endl; for (int i = 0; i < H; i++) { if (i != 0) cout << 1; else cout << 0; for (int j = 1; j < H; j++) { if (i != j) cout << " " << 1; else cout << " " << 0; } for (int j = H; j < W; j++) { if (((j - H) / 2) % H != i) cout << " " << 1; else cout << " " << 0; } cout << endl; } } } }