結果
問題 |
No.2509 Beam Shateki
|
ユーザー |
![]() |
提出日時 | 2025-01-14 15:40:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,050 ms / 2,000 ms |
コード長 | 1,350 bytes |
コンパイル時間 | 2,599 ms |
コンパイル使用メモリ | 207,484 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-14 15:41:28 |
合計ジャッジ時間 | 30,790 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 61 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int h, w; cin >> h >> w; vector<vector<int>> a(h + 2, vector<int>(w + 2, 0)); for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> a[i][j]; } } vector<pair<int, int>> out; for (int i = 0; i <= h + 1; i++) { out.push_back({i, 0}); out.push_back({i, w + 1}); } for (int i = 0; i <= w + 1; i++) { out.push_back({0, i}); out.push_back({h + 1, i}); } int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; int ans = 0; for (auto [i1, j1] : out) { for (int d1 = 0; d1 < 8; d1++) { int i = i1, j = j1; vector<vector<bool>> vis(h + 2, vector<bool>(w + 2, false)); int score_cur = 0; while (true) { vis[i][j] = true; score_cur += a[i][j]; i += dx[d1]; j += dy[d1]; if (i < 1 || i > h || j < 1 || j > w) { break; } } for (auto [i2, j2] : out) { for (int d2 = 0; d2 < 8; d2++) { int score = score_cur; int i = i2, j = j2; while (true) { if (!vis[i][j]) { score += a[i][j]; } i += dx[d2]; j += dy[d2]; if (i < 1 || i > h || j < 1 || j > w) { break; } } ans = max(ans, score); } } } } cout << ans << endl; }