結果

問題 No.2509 Beam Shateki
ユーザー cho435cho435
提出日時 2023-10-21 11:43:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 868 ms / 2,000 ms
コード長 1,269 bytes
コンパイル時間 1,060 ms
コンパイル使用メモリ 84,252 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 11:43:41
合計ジャッジ時間 25,574 ms
ジャッジサーバーID
(参考情報)
judge12 / 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 100 ms
4,348 KB
testcase_04 AC 99 ms
4,348 KB
testcase_05 AC 99 ms
4,348 KB
testcase_06 AC 99 ms
4,348 KB
testcase_07 AC 100 ms
4,348 KB
testcase_08 AC 99 ms
4,348 KB
testcase_09 AC 99 ms
4,348 KB
testcase_10 AC 100 ms
4,348 KB
testcase_11 AC 100 ms
4,348 KB
testcase_12 AC 99 ms
4,348 KB
testcase_13 AC 840 ms
4,348 KB
testcase_14 AC 838 ms
4,348 KB
testcase_15 AC 861 ms
4,348 KB
testcase_16 AC 834 ms
4,348 KB
testcase_17 AC 832 ms
4,348 KB
testcase_18 AC 856 ms
4,348 KB
testcase_19 AC 834 ms
4,348 KB
testcase_20 AC 831 ms
4,348 KB
testcase_21 AC 865 ms
4,348 KB
testcase_22 AC 838 ms
4,348 KB
testcase_23 AC 842 ms
4,348 KB
testcase_24 AC 839 ms
4,348 KB
testcase_25 AC 864 ms
4,348 KB
testcase_26 AC 835 ms
4,348 KB
testcase_27 AC 832 ms
4,348 KB
testcase_28 AC 859 ms
4,348 KB
testcase_29 AC 857 ms
4,348 KB
testcase_30 AC 836 ms
4,348 KB
testcase_31 AC 868 ms
4,348 KB
testcase_32 AC 837 ms
4,348 KB
testcase_33 AC 15 ms
4,348 KB
testcase_34 AC 179 ms
4,348 KB
testcase_35 AC 393 ms
4,348 KB
testcase_36 AC 96 ms
4,348 KB
testcase_37 AC 52 ms
4,348 KB
testcase_38 AC 66 ms
4,348 KB
testcase_39 AC 101 ms
4,348 KB
testcase_40 AC 216 ms
4,348 KB
testcase_41 AC 4 ms
4,348 KB
testcase_42 AC 138 ms
4,348 KB
testcase_43 AC 521 ms
4,348 KB
testcase_44 AC 648 ms
4,348 KB
testcase_45 AC 81 ms
4,348 KB
testcase_46 AC 200 ms
4,348 KB
testcase_47 AC 583 ms
4,348 KB
testcase_48 AC 137 ms
4,348 KB
testcase_49 AC 309 ms
4,348 KB
testcase_50 AC 323 ms
4,348 KB
testcase_51 AC 22 ms
4,348 KB
testcase_52 AC 232 ms
4,348 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 3 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 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 #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<iostream>
#include<array>
#include<set>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int h,w;
	cin>>h>>w;
	array<array<int,100>,100> a;
	rep(i,h) rep(j,w) cin>>a[i][j];
	array<int,4> dx={-1,0,1,1};
	array<int,4> dy={1,1,1,0};
	auto isok=[&](int x,int y){
		return 0<=x&&x<h&&0<=y&&y<w;
	};
	ll ans=0;
	rep(ch1,h+w-1){
		int x1=0,y1=0;
		if(ch1>=h) y1=ch1-h+1;
		else x1=ch1;
		rep(lp,2){
			for(int ch2=ch1;ch2<h+w-1;ch2++){
				int x2=0,y2=0;
				if(ch2>=h) y2=ch2-h+1;
				else x2=ch2;
				rep(rp,2){
					rep(i,4){
						int cx1=x1,cy1=y1;
						set<int> stl;
						ll res=0;
						while(isok(cx1,cy1)){
							res+=a[cx1][cy1];
							stl.insert(cx1+cy1*h);
							cx1+=dx[i];
							cy1+=dy[i];
						}
						rep(j,4){
							ll g2=0;
							int cx2=x2,cy2=y2;
							while(isok(cx2,cy2)){
								if(!stl.count(cx2+cy2*h)){
									g2+=a[cx2][cy2];
								}
								cx2+=dx[j];
								cy2+=dy[j];
							}
							ans=max(ans,res+g2);
						}
					}
					if(x2!=0) break;
					x2=h-1;
				}
			}
			if(x1!=0) break;
			x1=h-1;
		}
	}
	cout<<ans<<"\n";
}
0