結果

問題 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,277 ms
コンパイル使用メモリ 114,292 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-05-07 07:48:47
合計ジャッジ時間 5,117 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 11 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 56 ms
5,888 KB
testcase_04 AC 26 ms
5,376 KB
testcase_05 AC 16 ms
5,376 KB
testcase_06 AC 39 ms
5,376 KB
testcase_07 AC 27 ms
5,376 KB
testcase_08 AC 7 ms
5,376 KB
testcase_09 AC 42 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 AC 33 ms
5,376 KB
testcase_12 AC 55 ms
6,016 KB
testcase_13 AC 36 ms
5,376 KB
testcase_14 AC 21 ms
5,376 KB
testcase_15 AC 69 ms
6,400 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 AC 51 ms
5,632 KB
testcase_18 AC 7 ms
5,376 KB
testcase_19 AC 8 ms
5,376 KB
testcase_20 AC 26 ms
5,376 KB
testcase_21 AC 88 ms
7,424 KB
testcase_22 AC 85 ms
7,168 KB
testcase_23 AC 83 ms
7,296 KB
testcase_24 AC 86 ms
7,296 KB
testcase_25 AC 2 ms
5,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