結果

問題 No.2509 Beam Shateki
ユーザー Today03Today03
提出日時 2023-10-20 21:58:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,947 ms / 2,000 ms
コード長 1,546 bytes
コンパイル時間 3,788 ms
コンパイル使用メモリ 237,200 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 21:59:56
合計ジャッジ時間 53,805 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 207 ms
4,348 KB
testcase_04 AC 209 ms
4,348 KB
testcase_05 AC 208 ms
4,348 KB
testcase_06 AC 209 ms
4,348 KB
testcase_07 AC 208 ms
4,348 KB
testcase_08 AC 208 ms
4,348 KB
testcase_09 AC 207 ms
4,348 KB
testcase_10 AC 207 ms
4,348 KB
testcase_11 AC 208 ms
4,348 KB
testcase_12 AC 208 ms
4,348 KB
testcase_13 AC 1,871 ms
4,348 KB
testcase_14 AC 1,872 ms
4,348 KB
testcase_15 AC 1,868 ms
4,348 KB
testcase_16 AC 1,862 ms
4,348 KB
testcase_17 AC 1,846 ms
4,348 KB
testcase_18 AC 1,947 ms
4,348 KB
testcase_19 AC 1,872 ms
4,348 KB
testcase_20 AC 1,888 ms
4,348 KB
testcase_21 AC 1,870 ms
4,348 KB
testcase_22 AC 1,898 ms
4,348 KB
testcase_23 AC 1,839 ms
4,348 KB
testcase_24 AC 1,864 ms
4,348 KB
testcase_25 AC 1,853 ms
4,348 KB
testcase_26 AC 1,842 ms
4,348 KB
testcase_27 AC 1,879 ms
4,348 KB
testcase_28 AC 1,857 ms
4,348 KB
testcase_29 AC 1,844 ms
4,348 KB
testcase_30 AC 1,836 ms
4,348 KB
testcase_31 AC 1,865 ms
4,348 KB
testcase_32 AC 1,840 ms
4,348 KB
testcase_33 AC 27 ms
4,348 KB
testcase_34 AC 402 ms
4,348 KB
testcase_35 AC 883 ms
4,348 KB
testcase_36 AC 131 ms
4,348 KB
testcase_37 AC 5 ms
4,348 KB
testcase_38 AC 165 ms
4,348 KB
testcase_39 AC 123 ms
4,348 KB
testcase_40 AC 485 ms
4,348 KB
testcase_41 AC 3 ms
4,348 KB
testcase_42 AC 179 ms
4,348 KB
testcase_43 AC 1,124 ms
4,348 KB
testcase_44 AC 1,304 ms
4,348 KB
testcase_45 AC 121 ms
4,348 KB
testcase_46 AC 222 ms
4,348 KB
testcase_47 AC 1,316 ms
4,348 KB
testcase_48 AC 327 ms
4,348 KB
testcase_49 AC 543 ms
4,348 KB
testcase_50 AC 694 ms
4,348 KB
testcase_51 AC 22 ms
4,348 KB
testcase_52 AC 409 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 2 ms
4,348 KB
testcase_57 AC 2 ms
4,348 KB
testcase_58 AC 2 ms
4,348 KB
testcase_59 AC 3 ms
4,348 KB
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 3 ms
4,348 KB
testcase_62 AC 2 ms
4,348 KB
testcase_63 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0