結果

問題 No.2509 Beam Shateki
ユーザー 👑 NachiaNachia
提出日時 2023-10-20 21:30:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,671 bytes
コンパイル時間 1,023 ms
コンパイル使用メモリ 86,480 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 21:30:42
合計ジャッジ時間 3,234 ms
ジャッジサーバーID
(参考情報)
judge14 / 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 4 ms
4,348 KB
testcase_04 AC 5 ms
4,348 KB
testcase_05 AC 5 ms
4,348 KB
testcase_06 AC 5 ms
4,348 KB
testcase_07 AC 5 ms
4,348 KB
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 5 ms
4,348 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 AC 19 ms
4,348 KB
testcase_14 AC 19 ms
4,348 KB
testcase_15 AC 19 ms
4,348 KB
testcase_16 AC 20 ms
4,348 KB
testcase_17 AC 19 ms
4,348 KB
testcase_18 AC 19 ms
4,348 KB
testcase_19 AC 19 ms
4,348 KB
testcase_20 AC 19 ms
4,348 KB
testcase_21 AC 19 ms
4,348 KB
testcase_22 AC 19 ms
4,348 KB
testcase_23 AC 19 ms
4,348 KB
testcase_24 AC 19 ms
4,348 KB
testcase_25 AC 19 ms
4,348 KB
testcase_26 AC 19 ms
4,348 KB
testcase_27 AC 19 ms
4,348 KB
testcase_28 AC 19 ms
4,348 KB
testcase_29 AC 19 ms
4,348 KB
testcase_30 AC 19 ms
4,348 KB
testcase_31 AC 18 ms
4,348 KB
testcase_32 AC 19 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 6 ms
4,348 KB
testcase_35 AC 12 ms
4,348 KB
testcase_36 AC 4 ms
4,348 KB
testcase_37 AC 3 ms
4,348 KB
testcase_38 AC 4 ms
4,348 KB
testcase_39 AC 4 ms
4,348 KB
testcase_40 AC 7 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 4 ms
4,348 KB
testcase_43 AC 13 ms
4,348 KB
testcase_44 AC 15 ms
4,348 KB
testcase_45 AC 4 ms
4,348 KB
testcase_46 AC 6 ms
4,348 KB
testcase_47 AC 15 ms
4,348 KB
testcase_48 AC 6 ms
4,348 KB
testcase_49 AC 8 ms
4,348 KB
testcase_50 AC 9 ms
4,348 KB
testcase_51 AC 2 ms
4,348 KB
testcase_52 AC 7 ms
4,348 KB
testcase_53 WA -
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 #

#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);
    testcase();
    return 0;
}
0