結果

問題 No.2509 Beam Shateki
ユーザー FplusFplusFFplusFplusF
提出日時 2023-10-20 21:40:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,471 ms / 2,000 ms
コード長 1,984 bytes
コンパイル時間 2,480 ms
コンパイル使用メモリ 215,952 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 21:41:06
合計ジャッジ時間 42,352 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 182 ms
4,348 KB
testcase_04 AC 183 ms
4,348 KB
testcase_05 AC 182 ms
4,348 KB
testcase_06 AC 207 ms
4,348 KB
testcase_07 AC 182 ms
4,348 KB
testcase_08 AC 182 ms
4,348 KB
testcase_09 AC 182 ms
4,348 KB
testcase_10 AC 186 ms
4,348 KB
testcase_11 AC 182 ms
4,348 KB
testcase_12 AC 209 ms
4,348 KB
testcase_13 AC 1,433 ms
4,348 KB
testcase_14 AC 1,460 ms
4,348 KB
testcase_15 AC 1,471 ms
4,348 KB
testcase_16 AC 1,463 ms
4,348 KB
testcase_17 AC 1,439 ms
4,348 KB
testcase_18 AC 1,430 ms
4,348 KB
testcase_19 AC 1,431 ms
4,348 KB
testcase_20 AC 1,427 ms
4,348 KB
testcase_21 AC 1,436 ms
4,348 KB
testcase_22 AC 1,432 ms
4,348 KB
testcase_23 AC 1,444 ms
4,348 KB
testcase_24 AC 1,432 ms
4,348 KB
testcase_25 AC 1,432 ms
4,348 KB
testcase_26 AC 1,430 ms
4,348 KB
testcase_27 AC 1,429 ms
4,348 KB
testcase_28 AC 1,433 ms
4,348 KB
testcase_29 AC 1,446 ms
4,348 KB
testcase_30 AC 1,437 ms
4,348 KB
testcase_31 AC 1,429 ms
4,348 KB
testcase_32 AC 1,435 ms
4,348 KB
testcase_33 AC 29 ms
4,348 KB
testcase_34 AC 329 ms
4,348 KB
testcase_35 AC 712 ms
4,348 KB
testcase_36 AC 120 ms
4,348 KB
testcase_37 AC 7 ms
4,348 KB
testcase_38 AC 135 ms
4,348 KB
testcase_39 AC 113 ms
4,348 KB
testcase_40 AC 394 ms
4,348 KB
testcase_41 AC 3 ms
4,348 KB
testcase_42 AC 160 ms
4,348 KB
testcase_43 AC 853 ms
4,348 KB
testcase_44 AC 1,039 ms
4,348 KB
testcase_45 AC 112 ms
4,348 KB
testcase_46 AC 197 ms
4,348 KB
testcase_47 AC 1,038 ms
4,348 KB
testcase_48 AC 268 ms
4,348 KB
testcase_49 AC 460 ms
4,348 KB
testcase_50 AC 558 ms
4,348 KB
testcase_51 AC 22 ms
4,348 KB
testcase_52 AC 354 ms
4,348 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 3 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 3 ms
4,348 KB
testcase_58 AC 2 ms
4,348 KB
testcase_59 AC 2 ms
4,348 KB
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 2 ms
4,348 KB
testcase_62 AC 3 ms
4,348 KB
testcase_63 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
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(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll h,w;
    cin >> h >> w;
    vector<vector<ll>> a(h+2,vector<ll>(w+2,0));
    for(ll i=1;i<=h;i++){
        for(ll j=1;j<=w;j++){
            cin >> a[i][j];
        }
    }
    vector<pll> v;
    rep(i,h+2){
        rep(j,w+2){
            if(i==0||j==0||i==h+1||j==w+1) v.emplace_back(i,j);
        }
    }
    ll ans=0;
    for(auto [ai,aj]:v){
        for(ll di=-1;di<=1;di++){
            for(ll dj=-1;dj<=1;dj++){
                if(di==0&&dj==0) continue;
                ll now=0;
                set<pll> st;
                ll nai=ai,naj=aj;
                while(1<=nai+di&&nai+di<=h&&1<=naj+dj&&naj+dj<=w){
                    nai+=di;
                    naj+=dj;
                    st.insert({nai,naj});
                    now+=a[nai][naj];
                }
                for(auto [bi,bj]:v){
                    for(ll ei=-1;ei<=1;ei++){
                        for(ll ej=-1;ej<=1;ej++){
                            if(ei==0&&ej==0) continue;
                            ll nbi=bi,nbj=bj;
                            ll now2=now;
                            while(1<=nbi+ei&&nbi+ei<=h&&1<=nbj+ej&&nbj+ej<=w){
                                nbi+=ei;
                                nbj+=ej;
                                if(st.count({nbi,nbj})) continue;
                                now2+=a[nbi][nbj];
                            }
                            chmax(ans,now2);
                        }
                    }
                }
            }
        }
    }
    cout << ans << '\n';
}
0