結果

問題 No.2509 Beam Shateki
ユーザー kotatsugamekotatsugame
提出日時 2023-10-20 21:30:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,037 ms / 2,000 ms
コード長 1,146 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 72,560 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 21:31:27
合計ジャッジ時間 29,414 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 141 ms
4,348 KB
testcase_04 AC 141 ms
4,348 KB
testcase_05 AC 136 ms
4,348 KB
testcase_06 AC 138 ms
4,348 KB
testcase_07 AC 139 ms
4,348 KB
testcase_08 AC 137 ms
4,348 KB
testcase_09 AC 137 ms
4,348 KB
testcase_10 AC 137 ms
4,348 KB
testcase_11 AC 137 ms
4,348 KB
testcase_12 AC 137 ms
4,348 KB
testcase_13 AC 1,021 ms
4,348 KB
testcase_14 AC 1,020 ms
4,348 KB
testcase_15 AC 1,016 ms
4,348 KB
testcase_16 AC 1,037 ms
4,348 KB
testcase_17 AC 1,007 ms
4,348 KB
testcase_18 AC 1,024 ms
4,348 KB
testcase_19 AC 1,013 ms
4,348 KB
testcase_20 AC 1,027 ms
4,348 KB
testcase_21 AC 1,012 ms
4,348 KB
testcase_22 AC 997 ms
4,348 KB
testcase_23 AC 1,014 ms
4,348 KB
testcase_24 AC 1,010 ms
4,348 KB
testcase_25 AC 1,033 ms
4,348 KB
testcase_26 AC 1,006 ms
4,348 KB
testcase_27 AC 985 ms
4,348 KB
testcase_28 AC 1,010 ms
4,348 KB
testcase_29 AC 983 ms
4,348 KB
testcase_30 AC 1,007 ms
4,348 KB
testcase_31 AC 1,010 ms
4,348 KB
testcase_32 AC 1,000 ms
4,348 KB
testcase_33 AC 24 ms
4,348 KB
testcase_34 AC 241 ms
4,348 KB
testcase_35 AC 494 ms
4,348 KB
testcase_36 AC 98 ms
4,348 KB
testcase_37 AC 14 ms
4,348 KB
testcase_38 AC 113 ms
4,348 KB
testcase_39 AC 94 ms
4,348 KB
testcase_40 AC 288 ms
4,348 KB
testcase_41 AC 4 ms
4,348 KB
testcase_42 AC 130 ms
4,348 KB
testcase_43 AC 624 ms
4,348 KB
testcase_44 AC 722 ms
4,348 KB
testcase_45 AC 90 ms
4,348 KB
testcase_46 AC 162 ms
4,348 KB
testcase_47 AC 744 ms
4,348 KB
testcase_48 AC 200 ms
4,348 KB
testcase_49 AC 336 ms
4,348 KB
testcase_50 AC 428 ms
4,348 KB
testcase_51 AC 21 ms
4,348 KB
testcase_52 AC 260 ms
4,348 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 3 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 3 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 #

#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
int H,W;
int A[100][100];
int vis[100][100];
int d[3]={0,1,-1};
void f(pair<int,int>z,int dr,vector<pair<int,int> >&now)
{
	int dx=d[dr/3],dy=d[dr%3];
	int x=z.first,y=z.second;
	do{
		x+=dx,y+=dy;
		if(0<=x&&x<H&&0<=y&&y<W)now.push_back(make_pair(x,y));
		else break;
	}while(true);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>H>>W;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>A[i][j];
	vector<pair<int,int> >OUT;
	for(int i=-1;i<=H;i++)
	{
		OUT.push_back(make_pair(i,-1));
		OUT.push_back(make_pair(i,W));
	}
	for(int j=0;j<W;j++)
	{
		OUT.push_back(make_pair(-1,j));
		OUT.push_back(make_pair(H,j));
	}
	vector<pair<int,int> >now;
	int visT=0;
	int ans=0;
	for(int P=0;P<OUT.size();P++)for(int Q=P+1;Q<OUT.size();Q++)
	{
		for(int p=1;p<9;p++)for(int q=1;q<9;q++)
		{
			now.clear();
			f(OUT[P],p,now);
			f(OUT[Q],q,now);
			visT++;
			int ret=0;
			for(pair<int,int>z:now)
			{
				int x=z.first,y=z.second;
				if(vis[x][y]<visT)
				{
					vis[x][y]=visT;
					ret+=A[x][y];
				}
			}
			ans=max(ans,ret);
		}
	}
	cout<<ans<<endl;
}
0