結果

問題 No.2112 All 2x2 are Equal
ユーザー FplusFplusFFplusFplusF
提出日時 2022-10-28 22:41:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,082 bytes
コンパイル時間 2,626 ms
コンパイル使用メモリ 213,244 KB
実行使用メモリ 104,960 KB
最終ジャッジ日時 2023-09-20 05:50:50
合計ジャッジ時間 62,336 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
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 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i=0;i<(long long)(n);i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
const ll INF=(1ll<<60);
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int main(){
    double start=clock();
    srand((unsigned int)time(NULL));
    mt19937 mt(rand());
    ll h,w;
    cin >> h >> w;
    set<ll> st;
    rep(i,h*w) st.insert(i+1);
    while(true){
        double now=clock();
        if(1.6<(now-start)/CLOCKS_PER_SEC){
            cout << "No" << endl;
            return 0;
        }
        vector<vector<ll>> ans(h,vector<ll>(w,-1));
        ll s=0;
        rep(i,2){
            rep(j,2){
                ll k=mt()%(*rbegin(st));
                ans[i][j]=*st.upper_bound(k);
                st.erase(ans[i][j]);
                s+=ans[i][j];
            }
        }
        for(ll j=2;j<w;j++){
            ll k=mt()%(*rbegin(st));
            ans[0][j]=*st.upper_bound(k);
            st.erase(ans[0][j]);
        }
        for(ll i=2;i<h;i++){
            ll k=mt()%(*rbegin(st));
            ans[i][0]=*st.upper_bound(k);
            st.erase(ans[i][0]);
        }
        bool b=false;
        for(ll i=1;i<h;i++){
            for(ll j=1;j<w;j++){
                if(i==1&&j==1) continue;
                ll x=s-(ans[i-1][j-1]+ans[i-1][j]+ans[i][j-1]);
                if(st.count(x)){
                    ans[i][j]=x;
                    st.erase(x);
                }else{
                    b=true;
                    break;
                }
            }
            if(b) break;
        }
        if(b){
            set<ll> st2;
            rep(i,h*w) st2.insert(i+1);
            swap(st,st2);
        }else{
            cout << "Yes" << endl;
            rep(i,h){
                rep(j,w){
                    cout << ans[i][j] << " ";
                }
                cout << endl;
            }
            return 0;
        }
    }
}
0