結果

問題 No.2509 Beam Shateki
ユーザー umimelumimel
提出日時 2023-10-20 22:20:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,554 bytes
コンパイル時間 1,946 ms
コンパイル使用メモリ 179,176 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2023-10-20 22:21:20
合計ジャッジ時間 18,875 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 346 ms
4,348 KB
testcase_04 AC 320 ms
4,348 KB
testcase_05 AC 320 ms
4,348 KB
testcase_06 AC 321 ms
4,348 KB
testcase_07 AC 345 ms
4,348 KB
testcase_08 AC 320 ms
4,348 KB
testcase_09 AC 320 ms
4,348 KB
testcase_10 AC 319 ms
4,348 KB
testcase_11 AC 348 ms
4,348 KB
testcase_12 AC 320 ms
4,348 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 49 ms
4,348 KB
testcase_34 AC 578 ms
4,348 KB
testcase_35 AC 1,196 ms
4,348 KB
testcase_36 AC 221 ms
4,348 KB
testcase_37 AC 18 ms
4,348 KB
testcase_38 AC 246 ms
4,348 KB
testcase_39 AC 211 ms
4,348 KB
testcase_40 AC 694 ms
4,348 KB
testcase_41 AC 6 ms
4,348 KB
testcase_42 AC 297 ms
4,348 KB
testcase_43 AC 1,471 ms
4,348 KB
testcase_44 AC 1,825 ms
4,348 KB
testcase_45 AC 202 ms
4,348 KB
testcase_46 AC 370 ms
4,348 KB
testcase_47 AC 1,772 ms
4,348 KB
testcase_48 AC 472 ms
4,348 KB
testcase_49 AC 806 ms
4,348 KB
testcase_50 AC 991 ms
4,348 KB
testcase_51 AC 43 ms
4,348 KB
testcase_52 AC 617 ms
4,348 KB
testcase_53 AC 3 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 3 ms
4,348 KB
testcase_56 AC 3 ms
4,348 KB
testcase_57 AC 3 ms
4,348 KB
testcase_58 AC 3 ms
4,348 KB
testcase_59 AC 3 ms
4,348 KB
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 3 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>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const ll MOD1000000007 = 1000000007;
const ll MOD998244353 = 998244353;
const ll MOD[3] = {999727999, 1070777777, 1000000007};
const ll LINF = 1LL << 60LL;
const int IINF = (1 << 30) - 1;


void solve(){
    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];

    ll ans = 0;
    ll di[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
    ll dj[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
    vector<vector<bool>> visited(h+2, vector<bool>(w+2, false));
    for(ll i0=0; i0<=h+1; i0++) for(ll j0=0; j0<=w+1; j0++){
        if(!(i0==0 || i0==h+1 || j0==0 || j0==w+1)) continue;

        for(ll i1=0; i1<=h+1; i1++) for(ll j1=0; j1<=w+1; j1++){
            if(!(i1==0 || i1==h+1 || j1==0 || j1==w+1)) continue;

            for(ll k0=0; k0<8; k0++) for(ll k1=0; k1<8; k1++){
                ll sum = 0;
                {
                    ll now_i = i0, now_j = j0;
                    while(true){
                        now_i = now_i + di[k0], now_j = now_j + dj[k0];
                        if(now_i<=0 || now_i>=h+1 || now_j<=0 || now_j>=w+1) break;
                        sum += a[now_i][now_j];
                        visited[now_i][now_j] = true;
                    }
                }
                {
                    ll now_i = i1, now_j = j1;
                    while(true){
                        now_i = now_i + di[k1], now_j = now_j + dj[k1];
                        if(now_i<=0 || now_i>=h+1 || now_j<=0 || now_j>=w+1) break;
                        if(!visited[now_i][now_j]) sum += a[now_i][now_j];
                    }
                }
                {
                    ll now_i = i0, now_j = j0;
                    while(true){
                        now_i = now_i + di[k0], now_j = now_j + dj[k0];
                        if(now_i<=0 || now_i>=h+1 || now_j<=0 || now_j>=w+1) break;
                        visited[now_i][now_j] = false;
                    }
                }
                ans = max(ans, sum);
            }
        }
    }

    cout << ans << endl;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int T=1;
    //cin >> T;
    while(T--) solve();
}
0