結果

問題 No.1974 2x2 Flipper
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-05-14 08:33:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 1,517 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 111,352 KB
実行使用メモリ 7,292 KB
最終ジャッジ日時 2023-08-20 00:22:25
合計ジャッジ時間 6,247 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 11 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 58 ms
5,964 KB
testcase_04 AC 27 ms
4,500 KB
testcase_05 AC 16 ms
4,380 KB
testcase_06 AC 42 ms
5,164 KB
testcase_07 AC 27 ms
4,500 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 AC 43 ms
5,536 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 33 ms
4,808 KB
testcase_12 AC 58 ms
5,912 KB
testcase_13 AC 36 ms
5,036 KB
testcase_14 AC 21 ms
4,428 KB
testcase_15 AC 66 ms
6,364 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 48 ms
5,528 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 7 ms
4,380 KB
testcase_20 AC 26 ms
4,612 KB
testcase_21 AC 88 ms
7,292 KB
testcase_22 AC 86 ms
7,280 KB
testcase_23 AC 87 ms
7,292 KB
testcase_24 AC 87 ms
7,248 KB
testcase_25 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    int H, W;
    cin >> H >> W;
    vector<vector<int>> ans(H, vector<int>(W));
    if (H == 1 || W == 1){
        cout << 0 << endl;
    }
    else 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++) ans[i][j] = 1;
        }
    }
    else if (H % 2 == 0 && W % 2 == 1){
        cout << H*(W-1) << endl;
        for (int i=0; i<H; i++){
            for (int j=0; j<W-1; j++) ans[i][j] = 1;
        }
    }
    else if (H % 2 == 1 && W % 2 == 0){
        cout << (H-1)*W << endl;
        for (int i=0; i<H-1; i++){
            for (int j=0; j<W; j++) ans[i][j] = 1;
        }
    }
    else{
        for (int i=0; i<H; i++){
            for (int j=0; j<W; j++) ans[i][j] = 1;
        }
        if (H > W){
            cout << H * (W-1) << endl;
            for (int i=0; i<W; i++) ans[i][i] = 0;
            for (int i=W; i<H; i++) ans[i][W-1] = 0;
        }
        else{
            cout << (H-1) * W << endl;
            for (int i=0; i<H; i++) ans[i][i] = 0;
            for (int i=H; i<W; i++) ans[H-1][i] = 0;
        }
    }

    for (int i=0; i<H; i++){
        for (int j=0; j<W; j++) cout << ans[i][j] << " ";
        cout << endl;
    }

    return 0;
}
0