結果

問題 No.2509 Beam Shateki
ユーザー ococonomy1ococonomy1
提出日時 2023-10-29 16:14:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 4,021 bytes
コンパイル時間 1,757 ms
コンパイル使用メモリ 136,268 KB
実行使用メモリ 7,788 KB
最終ジャッジ日時 2023-10-29 16:15:12
合計ジャッジ時間 35,410 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,348 KB
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
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 #

// #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>
#include <unordered_set>
#include <utility>
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'

struct phash{
    size_t operator()(pair<int,int>const& p)const{
        return hash<int>()(p.first) ^ hash<int>()(p.second);
    }
};

#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 j = 0; j < i; j++){
            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;
                    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;
                            unordered_set<pii,phash> st;
                            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;
                                st.insert(pair(v[i].first + l * ix,v[i].second + l * iy));
                            }
                            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;
                                st.insert(pair(v[j].first + l * jx,v[j].second + l * jy));
                            }
                            int temp = 0;
                            while(!st.empty()){
                                temp += a[st.begin()->first][st.begin()->second];
                                st.erase(st.begin());
                            }
                            ans = max(ans,temp);
                        }
                    }
                }
            }
        }
    }
    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