結果

問題 No.2509 Beam Shateki
ユーザー maeshunmaeshun
提出日時 2023-10-20 22:06:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 832 ms / 2,000 ms
コード長 2,679 bytes
コンパイル時間 4,261 ms
コンパイル使用メモリ 240,092 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 22:06:28
合計ジャッジ時間 27,594 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 106 ms
4,348 KB
testcase_04 AC 106 ms
4,348 KB
testcase_05 AC 106 ms
4,348 KB
testcase_06 AC 107 ms
4,348 KB
testcase_07 AC 106 ms
4,348 KB
testcase_08 AC 107 ms
4,348 KB
testcase_09 AC 128 ms
4,348 KB
testcase_10 AC 107 ms
4,348 KB
testcase_11 AC 106 ms
4,348 KB
testcase_12 AC 107 ms
4,348 KB
testcase_13 AC 829 ms
4,348 KB
testcase_14 AC 827 ms
4,348 KB
testcase_15 AC 801 ms
4,348 KB
testcase_16 AC 812 ms
4,348 KB
testcase_17 AC 820 ms
4,348 KB
testcase_18 AC 826 ms
4,348 KB
testcase_19 AC 832 ms
4,348 KB
testcase_20 AC 830 ms
4,348 KB
testcase_21 AC 804 ms
4,348 KB
testcase_22 AC 802 ms
4,348 KB
testcase_23 AC 808 ms
4,348 KB
testcase_24 AC 817 ms
4,348 KB
testcase_25 AC 803 ms
4,348 KB
testcase_26 AC 829 ms
4,348 KB
testcase_27 AC 802 ms
4,348 KB
testcase_28 AC 803 ms
4,348 KB
testcase_29 AC 829 ms
4,348 KB
testcase_30 AC 802 ms
4,348 KB
testcase_31 AC 803 ms
4,348 KB
testcase_32 AC 803 ms
4,348 KB
testcase_33 AC 17 ms
4,348 KB
testcase_34 AC 188 ms
4,348 KB
testcase_35 AC 393 ms
4,348 KB
testcase_36 AC 96 ms
4,348 KB
testcase_37 AC 16 ms
4,348 KB
testcase_38 AC 87 ms
4,348 KB
testcase_39 AC 98 ms
4,348 KB
testcase_40 AC 225 ms
4,348 KB
testcase_41 AC 4 ms
4,348 KB
testcase_42 AC 135 ms
4,348 KB
testcase_43 AC 500 ms
4,348 KB
testcase_44 AC 595 ms
4,348 KB
testcase_45 AC 84 ms
4,348 KB
testcase_46 AC 193 ms
4,348 KB
testcase_47 AC 577 ms
4,348 KB
testcase_48 AC 155 ms
4,348 KB
testcase_49 AC 297 ms
4,348 KB
testcase_50 AC 322 ms
4,348 KB
testcase_51 AC 23 ms
4,348 KB
testcase_52 AC 223 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
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:38:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   38 |         auto [x_1, y_1] = vs[i];
      |              ^
main.cpp:39:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   39 |         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(j,h) vs.emplace_back(j,0);
    rep(i,w) vs.emplace_back(h-1,i);
    rep(i,h) vs.emplace_back(i,w-1);
    sort(vs.begin(),vs.end());
    vs.erase(unique(vs.begin(),vs.end()), vs.end());
    int n = vs.size();
    vector<vector<bool>> used(h, vector<bool>(w));
    rep(i,n){
      rep(j,i+1){
        auto [x_1, y_1] = vs[i];
        auto [x_2, y_2] = vs[j];
        for(int dx=0;dx<=1;dx++){
          for(int dy=-1;dy<=1;dy++){
            if(dx==0 && dy==0) continue;
            for(int ex=0;ex<=1;ex++){
              for(int ey=-1;ey<=1;ey++){
                if(ex==0 && ey==0) continue;
                ll sum = 0;
                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(!used[x1][y1]) sum += a[x1][y1];
                  used[x1][y1] = true;
                  x1 += dx;
                  y1 += dy;
                }
                while(true){
                  if(x2<0 || x2>=h || y2<0 || y2>=w) break;
                  if(!used[x2][y2]) sum += a[x2][y2];
                  used[x2][y2] = true;
                  x2 += ex;
                  y2 += ey;
                }
                x1 = x_1;
                y1 = y_1;
                x2 = x_2;
                y2 = y_2;
                while(true){
                  if(x1<0 || x1>=h || y1<0 || y1>=w) break;
                  used[x1][y1] = false;
                  x1 += dx;
                  y1 += dy;
                }
                while(true){
                  if(x2<0 || x2>=h || y2<0 || y2>=w) break;
                  used[x2][y2] = false;
                  x2 += ex;
                  y2 += ey;
                }
                ans = max(ans, sum);
              }
            }
          }
        }
      }
    }
    cout << ans << endl;
    return 0;
}
0