結果

問題 No.1974 2x2 Flipper
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2022-06-11 03:39:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,579 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 168,728 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 09:57:56
合計ジャッジ時間 5,768 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 13 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 66 ms
4,348 KB
testcase_04 AC 31 ms
4,348 KB
testcase_05 AC 18 ms
4,348 KB
testcase_06 AC 47 ms
4,348 KB
testcase_07 AC 32 ms
4,348 KB
testcase_08 AC 8 ms
4,348 KB
testcase_09 AC 49 ms
4,348 KB
testcase_10 AC 7 ms
4,348 KB
testcase_11 AC 39 ms
4,348 KB
testcase_12 AC 65 ms
4,348 KB
testcase_13 AC 40 ms
4,348 KB
testcase_14 AC 25 ms
4,348 KB
testcase_15 AC 76 ms
4,348 KB
testcase_16 AC 8 ms
4,348 KB
testcase_17 AC 54 ms
4,348 KB
testcase_18 AC 8 ms
4,348 KB
testcase_19 AC 8 ms
4,348 KB
testcase_20 AC 30 ms
4,348 KB
testcase_21 AC 100 ms
4,348 KB
testcase_22 AC 98 ms
4,348 KB
testcase_23 AC 97 ms
4,348 KB
testcase_24 AC 98 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @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;
}
0