結果
| 問題 | No.2509 Beam Shateki | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-10-20 21:35:22 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,026 ms / 2,000 ms | 
| コード長 | 1,784 bytes | 
| コンパイル時間 | 3,131 ms | 
| コンパイル使用メモリ | 261,840 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-20 17:39:01 | 
| 合計ジャッジ時間 | 30,944 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 61 | 
ソースコード
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
using namespace numbers;
int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int nr, nc;
	cin >> nr >> nc;
	vector<vector<int>> a(nr, vector<int>(nc));
	for(auto &x: a | ranges::views::join){
		cin >> x;
	}
	static const vector<pair<int, int>> dr8{{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
	int res = 0;
	for(auto [dx0, dy0]: dr8){
		for(auto x0 = 0; x0 < nr; ++ x0){
			for(auto y0 = 0; y0 < nc; ++ y0){
				if(x0 == 0 || x0 == nr - 1 || y0 == 0 || y0 == nc - 1){
					vector<vector<int>> vis(nr, vector<int>(nc));
					int temp = 0;
					for(auto x = x0, y = y0; 0 <= min(x, y) && x < nr && y < nc; x += dx0, y += dy0){
						vis[x][y] = true;
						temp += a[x][y];
					}
					for(auto [dx1, dy1]: dr8){
						for(auto x1 = 0; x1 < nr; ++ x1){
							for(auto y1 = 0; y1 < nc; ++ y1){
								if(x1 == 0 || x1 == nr - 1 || y1 == 0 || y1 == nc - 1){
									int cur = temp;
									for(auto x = x1, y = y1; 0 <= min(x, y) && x < nr && y < nc; x += dx1, y += dy1){
										if(!vis[x][y]){
											cur += a[x][y];
										}
									}
									if(res < cur){
										res = cur;
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout << res << "\n";
	return 0;
}
/*
*/
////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////
            
            
            
        