結果
問題 | No.2509 Beam Shateki |
ユーザー |
👑 ![]() |
提出日時 | 2023-10-20 21:30:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,701 bytes |
コンパイル時間 | 1,010 ms |
コンパイル使用メモリ | 84,688 KB |
最終ジャッジ日時 | 2025-02-17 08:36:04 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 TLE * 1 |
other | -- * 61 |
ソースコード
#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;}