結果

問題 No.2509 Beam Shateki
ユーザー 👑 NachiaNachia
提出日時 2023-10-20 21:30:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,701 bytes
コンパイル時間 922 ms
コンパイル使用メモリ 86,016 KB
実行使用メモリ 8,952 KB
最終ジャッジ日時 2023-10-20 21:30:11
合計ジャッジ時間 4,447 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
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 <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
using Modint = atcoder::static_modint<998244353>;
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;


void testcase(){
    int H, W; cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    rep(y,H) rep(x,W) cin >> A[y][x];
    auto f = [&](vector<vector<int>> B) -> int {
        vector<int> Z(H),X(W),C(H+W),V(H+W);
        rep(y,H) rep(x,W){
            int a = B[y][x];
            Z[y] += a; X[x] += a;
            C[y+x] += a;
            V[y-x+W] += a;
        }
        int ans = 0;
        ans = max(ans, *max_element(Z.begin(), Z.end()));
        ans = max(ans, *max_element(X.begin(), X.end()));
        ans = max(ans, *max_element(C.begin(), C.end()));
        ans = max(ans, *max_element(V.begin(), V.end()));
        return ans;
    };
    int ans = 0;
    rep(tt,2){
        rep(y,H){
            vector<vector<int>> B = A;
            int t = 0;
            rep(x,W){ t += B[y][x]; B[y][x] = 0; }
            ans = max(ans, t + f(move(B)));
        }
        rep(d,H+W-1){
            vector<vector<int>> B = A;
            int t = 0;
            rep(x,W) if(x<=d && d-x<H){ t += B[d-x][x]; B[d-x][x] = 0; }
            ans = max(ans, t + f(move(B)));
        }
        vector<vector<int>> buf(W, vector<int>(H));
        rep(y,H) rep(x,W) buf[x][y] = A[y][x];
        swap(A,buf);
        swap(H,W);
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T; cin >> T; rep(t,T)
    testcase();
    return 0;
}
0