結果
問題 |
No.2375 watasou and hibit's baseball
|
ユーザー |
![]() |
提出日時 | 2023-07-07 22:30:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,465 bytes |
コンパイル時間 | 2,065 ms |
コンパイル使用メモリ | 201,800 KB |
最終ジャッジ日時 | 2025-02-15 07:50:19 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 27 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template<class T> void chmin(T &a,T b){ if(a>b){ a=b; } } template<class T> void chmax(T &a,T b){ if(a<b){ a=b; } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll n,a,b; cin >> n >> a >> b; vector<ll> x(n),y(n),k(n); rep(i,n) cin >> x[i] >> y[i] >> k[i]; auto dist=[&](ll i,ll j){ return abs(x[i]-x[j])+abs(y[i]+y[j]); }; vector<vector<vector<ll>>> dp(1<<n,vector<vector<ll>>(n,vector<ll>(n,0))); rep(i,n){ rep(j,n){ if(i==j) continue; if(a<=dist(i,j)/*||b<=abs(k[i]-k[j])*/) dp[(1<<i)|(1<<j)][i][j]=1; } } rep(i,1<<n){ rep(j,n){ rep(l,n){ rep(m,n){ if(i&(1<<m)) continue; if(b<=abs(k[m]-k[j])||a<=dist(m,j)+dist(m,l)) dp[i|(1<<m)][m][j]|=dp[i][j][l]; } } } } auto cnt=[&](ll p){ ll ret=0; rep(i,n){ if(p&(1<<i)) ret++; } return ret; }; ll ans=1; rep(i,1<<n){ rep(j,n){ rep(k,n){ if(dp[i][j][k]) chmax(ans,cnt(i)); } } } cout << ans << '\n'; }