結果

問題 No.2509 Beam Shateki
ユーザー AerenAeren
提出日時 2023-10-20 21:35:22
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,064 ms / 2,000 ms
コード長 1,784 bytes
コンパイル時間 3,254 ms
コンパイル使用メモリ 261,816 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 21:36:03
合計ジャッジ時間 31,898 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 140 ms
4,348 KB
testcase_04 AC 137 ms
4,348 KB
testcase_05 AC 141 ms
4,348 KB
testcase_06 AC 134 ms
4,348 KB
testcase_07 AC 154 ms
4,348 KB
testcase_08 AC 137 ms
4,348 KB
testcase_09 AC 140 ms
4,348 KB
testcase_10 AC 143 ms
4,348 KB
testcase_11 AC 132 ms
4,348 KB
testcase_12 AC 137 ms
4,348 KB
testcase_13 AC 1,025 ms
4,348 KB
testcase_14 AC 1,062 ms
4,348 KB
testcase_15 AC 1,053 ms
4,348 KB
testcase_16 AC 1,064 ms
4,348 KB
testcase_17 AC 1,039 ms
4,348 KB
testcase_18 AC 1,005 ms
4,348 KB
testcase_19 AC 1,058 ms
4,348 KB
testcase_20 AC 1,006 ms
4,348 KB
testcase_21 AC 1,030 ms
4,348 KB
testcase_22 AC 1,044 ms
4,348 KB
testcase_23 AC 1,007 ms
4,348 KB
testcase_24 AC 1,026 ms
4,348 KB
testcase_25 AC 1,004 ms
4,348 KB
testcase_26 AC 1,022 ms
4,348 KB
testcase_27 AC 1,011 ms
4,348 KB
testcase_28 AC 1,027 ms
4,348 KB
testcase_29 AC 1,017 ms
4,348 KB
testcase_30 AC 1,026 ms
4,348 KB
testcase_31 AC 1,044 ms
4,348 KB
testcase_32 AC 1,004 ms
4,348 KB
testcase_33 AC 20 ms
4,348 KB
testcase_34 AC 241 ms
4,348 KB
testcase_35 AC 514 ms
4,348 KB
testcase_36 AC 102 ms
4,348 KB
testcase_37 AC 12 ms
4,348 KB
testcase_38 AC 113 ms
4,348 KB
testcase_39 AC 100 ms
4,348 KB
testcase_40 AC 303 ms
4,348 KB
testcase_41 AC 3 ms
4,348 KB
testcase_42 AC 140 ms
4,348 KB
testcase_43 AC 612 ms
4,348 KB
testcase_44 AC 743 ms
4,348 KB
testcase_45 AC 93 ms
4,348 KB
testcase_46 AC 198 ms
4,348 KB
testcase_47 AC 727 ms
4,348 KB
testcase_48 AC 224 ms
4,348 KB
testcase_49 AC 336 ms
4,348 KB
testcase_50 AC 410 ms
4,348 KB
testcase_51 AC 21 ms
4,348 KB
testcase_52 AC 263 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 1 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
権限があれば一括ダウンロードができます

ソースコード

diff #

#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                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////
0