結果
| 問題 |
No.2375 watasou and hibit's baseball
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-07 22:18:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 122 ms / 2,000 ms |
| コード長 | 1,379 bytes |
| コンパイル時間 | 2,245 ms |
| コンパイル使用メモリ | 205,784 KB |
| 最終ジャッジ日時 | 2025-02-15 07:40:53 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vll =vector<ll>;
using vvll =vector<vll>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vvvb=vector<vvb>;
#define rep(i,n) for(ll i=(ll)(0); i<(ll(n)); ++i)
#define all(x) (x).begin(), (x).end()
int main(){
ll N,A,B;
cin>>N>>A>>B;
vll X(N),Y(N),K(N);
rep(i,N)cin>>X[i]>>Y[i]>>K[i];
vvvb DP(1<<N,vvb(N,vb(N,0)));
rep(i,N)DP[1<<i][i][i]=1;
ll an=0;
rep(bit,1<<N){
rep(i,N){
rep(j,N){
if(DP[bit][i][j]){
ll cnt=0;
rep(k,N)if(bit&(1<<k))cnt++;
an=max(an,cnt);
rep(k,N){
if(bit&(1<<k))continue;
ll XS=abs(X[i]-X[k])+abs(Y[i]-Y[k]);
ll YS=abs(X[j]-X[k])+abs(Y[j]-Y[k]);
if(cnt==1){
if(A<=YS)DP[bit+(1<<k)][j][k]=true;
}
if(cnt>=1){
if(B<=abs(K[j]-K[k]))DP[bit+(1<<k)][j][k]=1;
}
if(cnt>=2){
if(A<=XS+YS)DP[bit+(1<<k)][j][k]=1;
}
}
}
}
}
}
cout<<an<<endl;
}