結果

問題 No.2375 watasou and hibit's baseball
ユーザー FplusFplusFFplusFplusF
提出日時 2023-07-07 22:45:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 305 ms / 2,000 ms
コード長 1,481 bytes
コンパイル時間 2,391 ms
コンパイル使用メモリ 206,356 KB
実行使用メモリ 37,980 KB
最終ジャッジ日時 2023-09-29 00:20:53
合計ジャッジ時間 8,538 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 102 ms
17,580 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 233 ms
37,648 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 47 ms
9,572 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 8 ms
4,684 KB
testcase_12 AC 301 ms
37,796 KB
testcase_13 AC 111 ms
17,676 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 24 ms
6,120 KB
testcase_16 AC 8 ms
4,604 KB
testcase_17 AC 244 ms
37,716 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 9 ms
4,584 KB
testcase_21 AC 220 ms
37,980 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 220 ms
37,668 KB
testcase_24 AC 209 ms
37,724 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 219 ms
37,664 KB
testcase_27 AC 243 ms
37,660 KB
testcase_28 AC 207 ms
37,672 KB
testcase_29 AC 190 ms
37,664 KB
testcase_30 AC 305 ms
37,728 KB
testcase_31 AC 270 ms
37,864 KB
testcase_32 AC 287 ms
37,780 KB
testcase_33 AC 268 ms
37,804 KB
testcase_34 AC 218 ms
37,668 KB
testcase_35 AC 212 ms
37,672 KB
testcase_36 AC 196 ms
37,668 KB
testcase_37 AC 241 ms
37,680 KB
testcase_38 AC 200 ms
37,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(1ll<<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[((1ll<<i)|(1ll<<j))][i][j]=1;
        }
    }
    rep(i,1ll<<n){
        rep(j,n){
            rep(l,n){
                rep(m,n){
                    if(i&(1ll<<m)) continue;
                    if(b<=abs(k[m]-k[j])||a<=dist(m,j)+dist(m,l)) dp[(i|(1ll<<m))][m][j]|=dp[i][j][l];
                }
            }
        }
    }
    auto cnt=[&](ll p){
        ll ret=0;
        rep(i,n){
            if(p&(1ll<<i)) ret++;
        }
        return ret;
    };
    ll ans=1;
    rep(i,1ll<<n){
        rep(j,n){
            rep(k,n){
                if(dp[i][j][k]) chmax(ans,cnt(i));
            }
        }
    }
    cout << ans << '\n';
}
0