結果
問題 | No.2375 watasou and hibit's baseball |
ユーザー |
![]() |
提出日時 | 2023-07-10 18:13:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 118 ms / 2,000 ms |
コード長 | 967 bytes |
コンパイル時間 | 4,238 ms |
コンパイル使用メモリ | 256,844 KB |
最終ジャッジ日時 | 2025-02-15 09:34:45 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#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 4000000000000000001int 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;}