結果
| 問題 |
No.2509 Beam Shateki
|
| コンテスト | |
| ユーザー |
Today03
|
| 提出日時 | 2023-10-20 21:58:34 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,935 ms / 2,000 ms |
| コード長 | 1,546 bytes |
| コンパイル時間 | 11,709 ms |
| コンパイル使用メモリ | 296,124 KB |
| 最終ジャッジ日時 | 2025-02-17 09:24:57 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 61 |
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
const vector<int> dx = {0, 1, 1, 1};
const vector<int> dy = {1, 0, 1, -1};
int main() {
int h, w;
cin >> h >> w;
vector<vector<int>> A(h, vector<int>(w));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> A[i][j];
}
}
vector<tuple<int, int, int>> start;
start.push_back(make_tuple(0, 0, 2));
for (int i = 1; i <= w; i++) {
start.push_back(make_tuple(0, i, 1));
start.push_back(make_tuple(0, i, 2));
start.push_back(make_tuple(0, i, 3));
}
start.push_back(make_tuple(0, w + 1, 3));
for (int i = 1; i <= h; i++) {
start.push_back(make_tuple(i, 0, 0));
start.push_back(make_tuple(i, 0, 2));
start.push_back(make_tuple(i, 0, 3));
start.push_back(make_tuple(i, w + 1, 3));
}
long long ans = 0;
for (tuple<int, int, int> T1 : start) {
for (tuple<int, int, int> T2 : start) {
long long res = 0;
int x1, y1, d1, x2, y2, d2;
tie(x1, y1, d1) = T1;
tie(x2, y2, d2) = T2;
x1 += dx[d1];
y1 += dy[d1];
x2 += dx[d2];
y2 += dy[d2];
set<pair<int, int>> st;
while (1 <= x1 && x1 <= h && 1 <= y1 && y1 <= w) {
res += A[x1 - 1][y1 - 1];
st.insert(make_pair(x1, y1));
x1 += dx[d1];
y1 += dy[d1];
}
while (1 <= x2 && x2 <= h && 1 <= y2 && y2 <= w) {
if (!st.count(make_pair(x2, y2))) {
res += A[x2 - 1][y2 - 1];
}
x2 += dx[d2];
y2 += dy[d2];
}
ans = max(ans, res);
}
}
cout << ans << endl;
}
Today03