結果
| 問題 | No.1974 2x2 Flipper |
| コンテスト | |
| ユーザー |
magsta
|
| 提出日時 | 2022-03-23 21:51:34 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 43 ms / 2,000 ms |
| コード長 | 1,680 bytes |
| 記録 | |
| コンパイル時間 | 940 ms |
| コンパイル使用メモリ | 182,252 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-09 14:03:49 |
| 合計ジャッジ時間 | 3,295 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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