結果

問題 No.1974 2x2 Flipper
ユーザー otoshigootoshigo
提出日時 2022-06-10 22:02:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,336 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 204,808 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 05:11:23
合計ジャッジ時間 6,915 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 9 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 44 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 31 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 36 ms
4,348 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 66 ms
4,348 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint1000000007;
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,a,b) for (int i = a; i < b; i++)
#define rrep2(i,a,b) for (int i = a-1; i >= b; i--)
#define rep3(i,a,b,c) for (int i = a; i < b; i+=c)
#define rrep3(i,a,b,c) for (int i = a-1; i >= b; i-=c)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int h,w;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>h>>w;
    if(h==1||w==1){
        cout<<0<<"\n";
        rep(i,h){
            rep(j,w)cout<<0<<" ";
            cout<<"\n";
        }
    }else if((h==2&&w%2==1)||(w==2&&h%2==1)){
        cout<<h*w-2<<"\n";
        if(h==2){
            rep(i,h){
                rep(j,w)cout<<(j<w-1?1:0)<<" ";
                cout<<"\n";
            }
        }else{
            rep(i,h){
                rep(j,w)cout<<(i<h-1?1:0)<<" ";
                cout<<"\n";
            }
        }
    }else if(h==3||w==3){
        if(h==3){
            if(w%2==1){
                cout<<(h-1)*(w-1)+2<<"\n";
                rep(i,h){
                    rep(j,w)cout<<((i==h-1&&j<w-2)||(i==h-2&&j==w-2)||(j==w-1&&i<h-2)?0:1)<<" ";
                    cout<<"\n";
                }
            }else{
                cout<<w*(h-1)<<"\n";
                rep(i,h){
                    rep(j,w)cout<<(i<h-1?1:0)<<" ";
                    cout<<"\n";
                }
            }
        }else{
            if(h%2==1){
                cout<<(h-1)*(w-1)+2<<"\n";
                rep(i,h){
                    rep(j,w)cout<<((i==h-1&&j<w-2)||(i==h-2&&j==w-2)||(j==w-1&&i<h-2)?0:1)<<" ";
                    cout<<"\n";
                }
            }else{
                cout<<h*(w-1)<<"\n";
                rep(i,h){
                    rep(j,w)cout<<(j<w-1?1:0)<<" ";
                    cout<<"\n";
                }
            }
        }
    }else{
        cout<<h*w<<"\n";
        rep(i,h){
            rep(j,w)cout<<1<<" ";
            cout<<"\n";
        }
    }
}
0