結果
| 問題 |
No.1974 2x2 Flipper
|
| コンテスト | |
| ユーザー |
magsta
|
| 提出日時 | 2022-03-23 21:51:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 2,000 ms |
| コード長 | 1,680 bytes |
| コンパイル時間 | 1,713 ms |
| コンパイル使用メモリ | 169,044 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-21 07:04:28 |
| 合計ジャッジ時間 | 4,884 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;
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;
}
}
}
}
magsta