結果

問題 No.2509 Beam Shateki
ユーザー ococonomy1ococonomy1
提出日時 2023-10-29 16:26:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 3,810 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 127,920 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-29 16:26:25
合計ジャッジ時間 12,851 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 54 ms
4,348 KB
testcase_04 AC 55 ms
4,348 KB
testcase_05 AC 54 ms
4,348 KB
testcase_06 AC 54 ms
4,348 KB
testcase_07 AC 55 ms
4,348 KB
testcase_08 AC 54 ms
4,348 KB
testcase_09 AC 53 ms
4,348 KB
testcase_10 AC 54 ms
4,348 KB
testcase_11 AC 54 ms
4,348 KB
testcase_12 AC 54 ms
4,348 KB
testcase_13 AC 326 ms
4,348 KB
testcase_14 AC 327 ms
4,348 KB
testcase_15 AC 325 ms
4,348 KB
testcase_16 AC 326 ms
4,348 KB
testcase_17 AC 325 ms
4,348 KB
testcase_18 AC 328 ms
4,348 KB
testcase_19 AC 326 ms
4,348 KB
testcase_20 AC 326 ms
4,348 KB
testcase_21 AC 326 ms
4,348 KB
testcase_22 AC 328 ms
4,348 KB
testcase_23 AC 325 ms
4,348 KB
testcase_24 AC 329 ms
4,348 KB
testcase_25 AC 328 ms
4,348 KB
testcase_26 AC 325 ms
4,348 KB
testcase_27 AC 326 ms
4,348 KB
testcase_28 AC 327 ms
4,348 KB
testcase_29 AC 326 ms
4,348 KB
testcase_30 AC 325 ms
4,348 KB
testcase_31 AC 325 ms
4,348 KB
testcase_32 AC 330 ms
4,348 KB
testcase_33 AC 11 ms
4,348 KB
testcase_34 AC 93 ms
4,348 KB
testcase_35 AC 164 ms
4,348 KB
testcase_36 AC 39 ms
4,348 KB
testcase_37 AC 22 ms
4,348 KB
testcase_38 AC 51 ms
4,348 KB
testcase_39 AC 39 ms
4,348 KB
testcase_40 AC 111 ms
4,348 KB
testcase_41 AC 3 ms
4,348 KB
testcase_42 AC 53 ms
4,348 KB
testcase_43 AC 203 ms
4,348 KB
testcase_44 AC 242 ms
4,348 KB
testcase_45 AC 38 ms
4,348 KB
testcase_46 AC 72 ms
4,348 KB
testcase_47 AC 238 ms
4,348 KB
testcase_48 AC 82 ms
4,348 KB
testcase_49 AC 117 ms
4,348 KB
testcase_50 AC 134 ms
4,348 KB
testcase_51 AC 12 ms
4,348 KB
testcase_52 AC 89 ms
4,348 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 2 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 2 ms
4,348 KB
testcase_63 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
// #define AMARI 1000000007
#define TIME_LIMIT 1980000
#define el '\n'
#define El '\n'

#define MULTI_TEST_CASE false
void solve(void) {
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(h + 2,vector<int>(w + 2,0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i + 1][j + 1];
        }
    }
    vector<pii> v;
    for(int i = 0; i < h + 2; i++){
        v.push_back(pair(i,0));
        v.push_back(pair(i,w + 1));
    }
    for(int j = 0; j < w + 2; j++){
        v.push_back(pair(0,j));
        v.push_back(pair(h + 1,j));
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    int m = v.size();
    int ans = 0;
    for(int i = 0; i < m; i++){
        for(int ix = -1; ix <= 1; ix++){
            for(int iy = -1; iy <= 1; iy++){
                if(ix == 0 && iy == 0)continue;
                if(v[i].first == 0 && ix == -1)continue;
                if(v[i].second == 0 && iy == -1)continue;
                if(v[i].first == h + 1 && ix == 1)continue;
                if(v[i].second == w + 1 && iy == 1)continue;
                vector<vector<bool>> vb(h + 2,vector<bool>(w + 2,false));
                int temp = 0;
                for(int l = 0; true; l++){
                    if(v[i].first + l * ix < 0)break;
                    if(v[i].first + l * ix >= h + 2)break;
                    if(v[i].second + l * iy < 0)break;
                    if(v[i].second + l * iy >= w + 2)break;
                    //cerr << v[i].first + l * ix << el;
                    //cerr << v[i].second + l * iy << el;
                    vb[v[i].first + l * ix][v[i].second + l * iy] = true;
                    temp += a[v[i].first + l * ix][v[i].second + l * iy];
                }

                for(int j = 0; j < i; j++){
                    for(int jx = -1; jx <= 1; jx++){
                        for(int jy = -1; jy <= 1; jy++){
                            if(jx == 0 && jy == 0)continue;
                            if(v[j].first == 0 && jx == -1)continue;
                            if(v[j].second == 0 && jy == -1)continue;
                            if(v[i].first == h + 1 && jx == 1)continue;
                            if(v[i].second == w + 1 && jy == 1)continue;
                            int temp2 = 0;
                            for(int l = 0; true; l++){
                                if(v[j].first + l * jx < 0)break;
                                if(v[j].first + l * jx >= h + 2)break;
                                if(v[j].second + l * jy < 0)break;
                                if(v[j].second + l * jy >= w + 2)break;
                                if(!vb[v[j].first + l * jx][v[j].second + l * jy])temp2 += a[v[j].first + l * jx][v[j].second + l * jy];
                            }
                            ans = max(ans,temp + temp2);
                        }
                    }
                }
            }
        }
    }
    cout << ans << el;
    return;
}

void calc(void) {
    return;
}

//WTFday1A
//ABC227D
//ECR156D
//ABC145E
//ABC325G
//ABC191C
//ABC191F

signed main(void) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE) cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}
0