結果

問題 No.2509 Beam Shateki
ユーザー maeshunmaeshun
提出日時 2023-10-20 21:53:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,186 bytes
コンパイル時間 4,305 ms
コンパイル使用メモリ 241,512 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-20 21:54:41
合計ジャッジ時間 7,800 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,696 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 TLE -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:37:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   37 |         auto [x_1, y_1] = vs[i];
      |              ^
main.cpp:38:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   38 |         auto [x_2, y_2] = vs[j];
      |              ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    rep(i,h)rep(j,w) cin >> a[i][j];
    ll ans = 0;
    vector<pair<int,int>> vs;
    rep(i,w) vs.emplace_back(0,i);
    rep(i,w) vs.emplace_back(h-1,i);
    rep(j,h) vs.emplace_back(j,0);
    rep(j,h) vs.emplace_back(j,w-1);
    sort(vs.begin(),vs.end());
    vs.erase(unique(vs.begin(),vs.end()), vs.end());
    int n = vs.size();
    rep(i,n){
      rep(j,i){
        auto [x_1, y_1] = vs[i];
        auto [x_2, y_2] = vs[j];
        for(int dx=-1;dx<=1;dx++){
          for(int dy=-1;dy<=1;dy++){
            for(int ex=-1;ex<=1;ex++){
              for(int ey=-1;ey<=1;ey++){
                if(dx==0 && dy==0) continue;
                if(ex==0 && ey==0) continue;
                ll sum = 0;
                set<pair<int, int>> st;
                int x1 = x_1;
                int y1 = y_1;
                int x2 = x_2;
                int y2 = y_2;
                while(true){
                  if(x1<0 || x1>=h || y1<0 || y1>=w) break;
                  if(!st.count(make_pair(x1,y1))) sum += a[x1][y1];
                  st.emplace(x1,y1);
                  x1 += dx;
                  y1 += dy;
                }
                while(true){
                  if(x2<0 || x2>=h || y2<0 || y2>=w) break;
                  if(!st.count(make_pair(x2,y2))) sum += a[x2][y2];
                  st.emplace(x2,y2);
                  x2 += ex;
                  y2 += ey;
                }
                ans = max(ans, sum);
              }
            }
          }
        }
      }
    }
    cout << ans << endl;
    return 0;
}
0