結果

問題 No.2509 Beam Shateki
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-10-20 21:47:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,488 bytes
コンパイル時間 1,967 ms
コンパイル使用メモリ 208,076 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 21:48:20
合計ジャッジ時間 13,041 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 346 ms
4,348 KB
testcase_04 AC 357 ms
4,348 KB
testcase_05 AC 345 ms
4,348 KB
testcase_06 AC 376 ms
4,348 KB
testcase_07 AC 338 ms
4,348 KB
testcase_08 AC 344 ms
4,348 KB
testcase_09 AC 350 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 346 ms
4,348 KB
testcase_12 AC 339 ms
4,348 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 57 ms
4,348 KB
testcase_34 AC 662 ms
4,348 KB
testcase_35 AC 1,582 ms
4,348 KB
testcase_36 AC 260 ms
4,348 KB
testcase_37 AC 28 ms
4,348 KB
testcase_38 AC 305 ms
4,348 KB
testcase_39 AC 241 ms
4,348 KB
testcase_40 AC 784 ms
4,348 KB
testcase_41 AC 7 ms
4,348 KB
testcase_42 AC 341 ms
4,348 KB
testcase_43 AC 1,712 ms
4,348 KB
testcase_44 TLE -
testcase_45 AC 235 ms
4,348 KB
testcase_46 AC 447 ms
4,348 KB
testcase_47 TLE -
testcase_48 AC 538 ms
4,348 KB
testcase_49 AC 901 ms
4,348 KB
testcase_50 AC 1,131 ms
4,348 KB
testcase_51 AC 49 ms
4,348 KB
testcase_52 AC 678 ms
4,348 KB
testcase_53 AC 3 ms
4,348 KB
testcase_54 AC 3 ms
4,348 KB
testcase_55 AC 3 ms
4,348 KB
testcase_56 AC 3 ms
4,348 KB
testcase_57 AC 2 ms
4,348 KB
testcase_58 AC 3 ms
4,348 KB
testcase_59 AC 3 ms
4,348 KB
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 2 ms
4,348 KB
testcase_62 AC 3 ms
4,348 KB
testcase_63 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int B[111][111];
int A[111][111];
int R, C;
stack<pair<int, int>> st;
int calc(int ni, int nj, int di, int dj) {
	ni += di; nj += dj;
	int ret = 0;
	while (true) {
		if (ni <= 0 || ni > R || nj <= 0 || nj > C) break;
		if (B[ni][nj] <= 0) break;
		ret += B[ni][nj];
		B[ni][nj] = 0;
		st.emplace(ni, nj);
		ni += di; nj += dj;
	}
	return ret;
}
void fuku() {
	while (!st.empty()) {
		auto [i, j] = st.top();
		st.pop();
		B[i][j] = A[i][j];
	}
}
int main() {
	cin >> R >> C;
	for (auto& a : A) {
		fill(a, a + (C + 10), 0);
	}
	for (int i = 1; i <= R; i ++) {
		for (int j = 1; j <= C; j ++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i <= R + 1; i ++) {
		for (int j = 0; j <= C + 1; j ++) {
			B[i][j] = A[i][j];
		}
	}
	int ans = 0;
	for (int i1 = 0; i1 <= R + 1; i1 ++) {
		for (int j1 = 0; j1 <= C + 1; j1 ++) {
			if (0 < i1 && i1 <= R && 0 < j1 && j1 <= C) continue;
			for (int di = -1; di < 2; di ++) {
				for (int dj = -1; dj < 2; dj ++) {
					if (di == 0 && dj == 0) continue;
					for (int i2 = 0; i2 <= R + 1; i2 ++) {
						for (int j2 = 0; j2 <= C + 1; j2 ++) {
							if (0 < i2 && i2 <= R && 0 < j2 && j2 <= C) continue;
							for (int di2 = -1; di2 < 2; di2 ++) {
								for (int dj2 = -1; dj2 < 2; dj2 ++) {
									if (di2 == 0 && dj2 == 0) continue;
									ans = max(ans, calc(i1, j1, di, dj) + calc(i2, j2, di2, dj2));
									fuku();
								}
							}
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}
0