結果

問題 No.2509 Beam Shateki
ユーザー FplusFplusFFplusFplusF
提出日時 2023-10-20 21:34:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,024 bytes
コンパイル時間 2,149 ms
コンパイル使用メモリ 216,272 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-20 21:34:20
合計ジャッジ時間 9,635 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,888 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 370 ms
4,348 KB
testcase_04 AC 396 ms
4,348 KB
testcase_05 AC 388 ms
4,348 KB
testcase_06 AC 370 ms
4,348 KB
testcase_07 AC 393 ms
4,348 KB
testcase_08 AC 374 ms
4,348 KB
testcase_09 AC 379 ms
4,348 KB
testcase_10 AC 392 ms
4,348 KB
testcase_11 AC 365 ms
4,348 KB
testcase_12 AC 361 ms
4,348 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
権限があれば一括ダウンロードができます

ソースコード

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(auto [bi,bj]: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(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