結果

問題 No.2375 watasou and hibit's baseball
ユーザー 沙耶花沙耶花
提出日時 2023-07-10 18:13:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 967 bytes
コンパイル時間 4,295 ms
コンパイル使用メモリ 263,976 KB
実行使用メモリ 20,236 KB
最終ジャッジ日時 2023-10-10 01:15:10
合計ジャッジ時間 7,082 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 29 ms
11,008 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 123 ms
19,776 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 11 ms
7,064 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 4 ms
4,356 KB
testcase_12 AC 51 ms
19,760 KB
testcase_13 AC 22 ms
10,968 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 9 ms
5,068 KB
testcase_16 AC 6 ms
4,352 KB
testcase_17 AC 49 ms
20,028 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,352 KB
testcase_20 AC 4 ms
4,352 KB
testcase_21 AC 48 ms
20,016 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 47 ms
19,996 KB
testcase_24 AC 48 ms
19,992 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 59 ms
20,028 KB
testcase_27 AC 64 ms
19,776 KB
testcase_28 AC 69 ms
20,236 KB
testcase_29 AC 71 ms
19,760 KB
testcase_30 AC 79 ms
19,772 KB
testcase_31 AC 73 ms
19,760 KB
testcase_32 AC 80 ms
20,104 KB
testcase_33 AC 65 ms
19,972 KB
testcase_34 AC 62 ms
19,804 KB
testcase_35 AC 79 ms
20,108 KB
testcase_36 AC 73 ms
19,836 KB
testcase_37 AC 62 ms
19,836 KB
testcase_38 AC 47 ms
20,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main(){
	
	int N,A,B;
	cin>>N>>A>>B;
	
	vector<int> x(N),y(N),K(N);
	rep(i,N){
		cin>>x[i]>>y[i]>>K[i];
	}
	
	vector dp(1<<N,vector(N,vector<bool>(N,false)));
	rep(i,N){
		dp[1<<i][i][i] = true;
	}
	rep(i,1<<N){
		rep(j,N){
			rep(k,N){
				if(dp[i][j][k]==false)continue;
				rep(l,N){
					if((i>>l)&1)continue;
					bool f = false;
					if(abs(K[k]-K[l])>=B)f = true;
					int dist = abs(x[k]-x[l]) + abs(y[k]-y[l]);
					if(j!=k)dist += abs(x[l]-x[j]) + abs(y[l]-y[j]);
					if(dist >= A)f = true;
					if(f)dp[i|(1<<l)][k][l] = true;
				}
			}
		}
	}
	int ans = 1;
	rep(i,1<<N){
		rep(j,N){
			rep(k,N){
				if(dp[i][j][k])ans = max(ans,__builtin_popcount(i));
			}
		}
	}
	cout<<ans<<endl;
	
	return 0;
}
0