結果

問題 No.2375 watasou and hibit's baseball
ユーザー FplusFplusFFplusFplusF
提出日時 2023-07-07 22:18:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,643 bytes
コンパイル時間 2,864 ms
コンパイル使用メモリ 214,896 KB
実行使用メモリ 41,576 KB
最終ジャッジ日時 2023-09-28 23:41:03
合計ジャッジ時間 5,281 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 26 ms
17,792 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 152 ms
41,576 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 12 ms
10,008 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 3 ms
4,592 KB
testcase_12 AC 46 ms
37,808 KB
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 10 ms
6,200 KB
testcase_16 AC 5 ms
4,692 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,736 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 44 ms
37,752 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 84 ms
39,464 KB
testcase_31 AC 76 ms
39,036 KB
testcase_32 WA -
testcase_33 AC 76 ms
38,668 KB
testcase_34 WA -
testcase_35 AC 103 ms
39,656 KB
testcase_36 AC 79 ms
39,084 KB
testcase_37 WA -
testcase_38 AC 45 ms
37,884 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(1<<n,vector<vector<ll>>(n,vector<ll>(n,0)));
    queue<tll> q;
    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;
                q.push({((1<<i)|(1<<j)),i,j});
            }
        }
    }
    while(!q.empty()){
        ll i,j,l;
        tie(i,j,l)=q.front();
        q.pop();
        rep(m,n){
            if(i&(1<<m)) continue;
            if(b<=abs(k[m]-k[j])||a<=dist(m,j)+dist(m,l)){
                if(dp[i|(1<<m)][m][j]) continue;
                dp[i|(1<<m)][m][j]=1;
                q.push({(i|(1<<m)),m,j});
            }
        }
    }
    auto cnt=[&](ll x){
        ll ret=0;
        rep(i,n){
            if(x&(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';
}
0