結果

問題 No.1974 2x2 Flipper
ユーザー HaaHaa
提出日時 2022-06-10 22:12:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 1,230 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 168,772 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 05:57:45
合計ジャッジ時間 5,193 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 9 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 45 ms
4,348 KB
testcase_04 AC 30 ms
4,348 KB
testcase_05 AC 14 ms
4,348 KB
testcase_06 AC 33 ms
4,348 KB
testcase_07 AC 22 ms
4,348 KB
testcase_08 AC 8 ms
4,348 KB
testcase_09 AC 35 ms
4,348 KB
testcase_10 AC 5 ms
4,348 KB
testcase_11 AC 37 ms
4,348 KB
testcase_12 AC 65 ms
4,348 KB
testcase_13 AC 40 ms
4,348 KB
testcase_14 AC 18 ms
4,348 KB
testcase_15 AC 53 ms
4,348 KB
testcase_16 AC 6 ms
4,348 KB
testcase_17 AC 37 ms
4,348 KB
testcase_18 AC 6 ms
4,348 KB
testcase_19 AC 6 ms
4,348 KB
testcase_20 AC 29 ms
4,348 KB
testcase_21 AC 69 ms
4,348 KB
testcase_22 AC 68 ms
4,348 KB
testcase_23 AC 98 ms
4,348 KB
testcase_24 AC 70 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;

int main(){
    int h, w; cin >> h >> w;
    if(h%2==0&&w%2==0){
        cout << h*w << endl;
        REP(i,h)REP(j,w) cout << 1 << " \n"[j==w-1];
    }
    else if(h%2==1&&w%2==1){
        cout << h*w-max(h,w) << endl;
        REP(i,h)REP(j,w){
            int f=1;
            if(i==j)
                f=0;
            else if(i==h-1&&j>=h)
                f=0;
            else if(j==w-1&&i>=w)
                f=0;
            cout << f << " \n"[j==w-1];
        }
    }
    else if(h%2==1){
        cout << h*w-w << endl;
        REP(i,h-1)REP(j,w) cout << 1 << " \n"[j==w-1];
        REP(j,w) cout << 0 << " \n"[j==w-1];
    }
    else{
        cout << h*w-h << endl;
        REP(i,h){
            REP(j,w-1) cout << 1 << " ";
            cout << 0 << endl;
        }
    }
    return 0;
}
0