結果

問題 No.2375 watasou and hibit's baseball
ユーザー kotatsugamekotatsugame
提出日時 2023-07-07 21:37:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 904 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 68,312 KB
実行使用メモリ 6,672 KB
最終ジャッジ日時 2023-09-28 22:38:02
合計ジャッジ時間 2,654 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 8 ms
4,700 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 63 ms
6,652 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 7 ms
5,352 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 14 ms
6,032 KB
testcase_27 AC 19 ms
6,672 KB
testcase_28 AC 21 ms
6,572 KB
testcase_29 AC 24 ms
6,488 KB
testcase_30 AC 28 ms
6,496 KB
testcase_31 AC 25 ms
4,888 KB
testcase_32 AC 30 ms
5,112 KB
testcase_33 AC 20 ms
6,484 KB
testcase_34 AC 16 ms
6,228 KB
testcase_35 AC 28 ms
6,520 KB
testcase_36 AC 23 ms
6,380 KB
testcase_37 AC 15 ms
5,608 KB
testcase_38 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
bool dp[1<<14][14][14];
int N,A,B;
int X[14],Y[14],K[14];
int dist(int i,int j)
{
	return abs(X[i]-X[j])+abs(Y[i]-Y[j]);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>A>>B;
	for(int i=0;i<N;i++)cin>>X[i]>>Y[i]>>K[i];
	int ans=1;
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)if(i!=j)
	{
		//i, j
		bool ok=false;
		{//2
			if(A<=dist(i,j))ok=true;
		}
		{//3
			if(B<=abs(K[i]-K[j]))ok=true;
		}
		if(ok)
		{
			ans=2;
			dp[1<<i|1<<j][i][j]=true;
		}
	}
	for(int i=0;i<1<<N;i++)for(int j=0;j<N;j++)for(int k=0;k<N;k++)if(dp[i][j][k])
	{
		ans=max(ans,__builtin_popcount(i));
		for(int l=0;l<N;l++)if(!(i>>l&1))
		{
			bool ok=false;
			{//3
				if(B<=abs(K[l]-K[k]))ok=true;
			}
			{//4
				if(A<=dist(j,l)+dist(k,l))ok=true;
			}
			if(ok)
			{
				dp[i|1<<l][k][l]=true;
			}
		}
	}
	cout<<ans<<endl;
}
0