結果

問題 No.2509 Beam Shateki
ユーザー ripityripity
提出日時 2023-10-20 22:08:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 340 ms / 2,000 ms
コード長 1,103 bytes
コンパイル時間 2,530 ms
コンパイル使用メモリ 223,288 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 22:08:58
合計ジャッジ時間 13,846 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 75 ms
4,348 KB
testcase_04 AC 75 ms
4,348 KB
testcase_05 AC 75 ms
4,348 KB
testcase_06 AC 75 ms
4,348 KB
testcase_07 AC 75 ms
4,348 KB
testcase_08 AC 75 ms
4,348 KB
testcase_09 AC 75 ms
4,348 KB
testcase_10 AC 74 ms
4,348 KB
testcase_11 AC 74 ms
4,348 KB
testcase_12 AC 75 ms
4,348 KB
testcase_13 AC 339 ms
4,348 KB
testcase_14 AC 314 ms
4,348 KB
testcase_15 AC 314 ms
4,348 KB
testcase_16 AC 315 ms
4,348 KB
testcase_17 AC 340 ms
4,348 KB
testcase_18 AC 314 ms
4,348 KB
testcase_19 AC 315 ms
4,348 KB
testcase_20 AC 316 ms
4,348 KB
testcase_21 AC 315 ms
4,348 KB
testcase_22 AC 314 ms
4,348 KB
testcase_23 AC 315 ms
4,348 KB
testcase_24 AC 316 ms
4,348 KB
testcase_25 AC 315 ms
4,348 KB
testcase_26 AC 315 ms
4,348 KB
testcase_27 AC 314 ms
4,348 KB
testcase_28 AC 338 ms
4,348 KB
testcase_29 AC 314 ms
4,348 KB
testcase_30 AC 313 ms
4,348 KB
testcase_31 AC 315 ms
4,348 KB
testcase_32 AC 316 ms
4,348 KB
testcase_33 AC 20 ms
4,348 KB
testcase_34 AC 113 ms
4,348 KB
testcase_35 AC 191 ms
4,348 KB
testcase_36 AC 55 ms
4,348 KB
testcase_37 AC 4 ms
4,348 KB
testcase_38 AC 58 ms
4,348 KB
testcase_39 AC 51 ms
4,348 KB
testcase_40 AC 128 ms
4,348 KB
testcase_41 AC 4 ms
4,348 KB
testcase_42 AC 66 ms
4,348 KB
testcase_43 AC 223 ms
4,348 KB
testcase_44 AC 252 ms
4,348 KB
testcase_45 AC 53 ms
4,348 KB
testcase_46 AC 76 ms
4,348 KB
testcase_47 AC 252 ms
4,348 KB
testcase_48 AC 96 ms
4,348 KB
testcase_49 AC 142 ms
4,348 KB
testcase_50 AC 165 ms
4,348 KB
testcase_51 AC 16 ms
4,348 KB
testcase_52 AC 118 ms
4,348 KB
testcase_53 AC 6 ms
4,348 KB
testcase_54 AC 3 ms
4,348 KB
testcase_55 AC 3 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 3 ms
4,348 KB
testcase_58 AC 3 ms
4,348 KB
testcase_59 AC 2 ms
4,348 KB
testcase_60 AC 3 ms
4,348 KB
testcase_61 AC 3 ms
4,348 KB
testcase_62 AC 3 ms
4,348 KB
testcase_63 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	vector<int> x = {1, 0, 1, 1};
	vector<int> y = {0, 1, 1, -1};
	vector<map<int, long long>> s(4);
	vector<vector<long long>> A(H, vector<long long>(W));
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			cin >> A[i][j];
			for( int k = 0; k < 4; k++ ) {
				s[k][x[k]*i+y[k]*j] += A[i][j];
			}
		}
	}
	long long ans = 0;
	for( auto [i, j] : s[2] ) {
	  for( auto [k, l] : s[3] ) {
	    if( abs(i-k)%2 == 1 ) ans = max(ans, j+l);
	  }
	}
	for( int i = -2*H; i <= 3*H; i++ ) {
		for( int j = -2*W; j <= 3*W; j++ ) {
			for( int k = 0; k < 4; k++ ) {
				for( int l = 0; l < 4; l++ ) {
				  if( k == l ) continue;
					if( 0 <= i && i < H && 0 <= j && j < W ) ans = max(ans, s[k][x[k]*i+y[k]*j]+s[l][x[l]*i+y[l]*j]-A[i][j]);
					else ans = max(ans, s[k][x[k]*i+y[k]*j]+s[l][x[l]*i+y[l]*j]);
				}
			}
		}
	}
	for( int i = 0; i < 4; i++ ) {
		vector<long long> v = {0};
		for( auto [j, k] : s[i] ) v.push_back(k);
		sort(v.rbegin(), v.rend());
		ans = max(ans, v[0]+v[1]);
	}
	cout << ans << endl;
}
0