結果

問題 No.1974 2x2 Flipper
ユーザー pockynypockyny
提出日時 2022-06-10 22:07:27
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,829 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 69,796 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 05:57:39
合計ジャッジ時間 4,250 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 11 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 62 ms
4,348 KB
testcase_04 AC 29 ms
4,348 KB
testcase_05 AC 18 ms
4,348 KB
testcase_06 AC 44 ms
4,348 KB
testcase_07 AC 29 ms
4,348 KB
testcase_08 AC 7 ms
4,348 KB
testcase_09 AC 46 ms
4,348 KB
testcase_10 AC 7 ms
4,348 KB
testcase_11 AC 36 ms
4,348 KB
testcase_12 AC 60 ms
4,348 KB
testcase_13 AC 37 ms
4,348 KB
testcase_14 AC 24 ms
4,348 KB
testcase_15 AC 68 ms
4,348 KB
testcase_16 AC 7 ms
4,348 KB
testcase_17 AC 49 ms
4,348 KB
testcase_18 AC 6 ms
4,348 KB
testcase_19 AC 8 ms
4,348 KB
testcase_20 AC 26 ms
4,348 KB
testcase_21 AC 88 ms
4,348 KB
testcase_22 AC 92 ms
4,348 KB
testcase_23 AC 87 ms
4,348 KB
testcase_24 AC 91 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
int main(){
    int i,j,h,w; cin >> h >> w;
    if(h==1){
        cout << 0 << endl;
        for(i=0;i<w;i++) cout << 0 << " ";
        cout << endl;
        return 0;
    }
    if(w==1){
        cout << 0 << endl;
        for(i=0;i<h;i++) cout << 0 << "\n";
        return 0;
    }
    if(h&1 && w&1){
        int ans = 0;
        if(h>=w){
            cout << h*(w - 1) << endl;
            for(i=0;i<w;i++){
                for(j=0;j<w;j++){
                    if(i==j) cout << 0 <<  " ";
                    else cout << 1 << " ";  
                }
                cout << endl;
            }
            for(i=w;i<h;i++){
                for(j=0;j<w - 1;j++){
                    cout << 1 << " ";
                }
                cout << 0 << " ";
                cout << endl;
            }
        }else{
            cout << w*(h - 1) << endl;
            for(i=0;i<h;i++){
                for(j=0;j<h;j++){
                    if(i==j) cout << 0 << " ";
                    else cout << 1 << " ";
                }
                for(j=h;j<w;j++){
                    if(i<h - 1) cout << 1 << " ";
                    else cout << 0 << " ";
                }
                cout << "\n";
            }
        }
    }else if(h&1){
        cout << (h - 1)*w << endl;
        for(i=0;i<h - 1;i++){
            for(j=0;j<w;j++) cout << 1 << " ";
            cout << endl;
        }
        for(i=0;i<w;i++) cout << 0 << " ";
        cout << endl;
    }else if(w&1){
        cout << h*(w - 1) << endl;
        for(i=0;i<h;i++){
            for(j=0;j<w - 1;j++) cout << 1 << " ";
            cout << 0 << "\n";
        }
    }else{
        cout << h*w << endl;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++) cout << 1 << " ";
            cout << endl;
        }
    }
}
0