結果

問題 No.2375 watasou and hibit's baseball
ユーザー i_am_noobi_am_noob
提出日時 2023-07-07 21:28:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,073 bytes
コンパイル時間 2,010 ms
コンパイル使用メモリ 199,504 KB
実行使用メモリ 6,752 KB
最終ジャッジ日時 2023-09-28 22:25:08
合計ジャッジ時間 4,910 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 10 ms
4,836 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 55 ms
6,560 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 12 ms
5,336 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 10 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 9 ms
4,380 KB
testcase_24 AC 9 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 17 ms
6,136 KB
testcase_27 AC 20 ms
6,680 KB
testcase_28 AC 22 ms
6,276 KB
testcase_29 AC 24 ms
6,392 KB
testcase_30 AC 30 ms
6,568 KB
testcase_31 AC 26 ms
5,132 KB
testcase_32 AC 32 ms
5,004 KB
testcase_33 AC 22 ms
6,752 KB
testcase_34 AC 19 ms
6,012 KB
testcase_35 AC 29 ms
6,544 KB
testcase_36 AC 25 ms
6,348 KB
testcase_37 AC 20 ms
5,524 KB
testcase_38 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;

#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) ((int)a.size())

const int N=14;
int n,x[N],y[N],k[N],A,B;
bool dp[1<<N][N][N];

int dis(int i, int j){return abs(x[i]-x[j])+abs(y[i]-y[j]);}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> A >> B;
    for(int i=0; i<n; ++i) cin >> x[i] >> y[i] >> k[i];
    for(int i=0; i<n; ++i) dp[1<<i][i][i]=1;
    for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) if(i!=j&&(dis(i,j)>=A||abs(k[i]-k[j])>=B)) dp[(1<<i)+(1<<j)][i][j]=1;
    for(int s=0; s<(1<<n); ++s) if(__builtin_popcount(s)>=2){
        for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) if(dp[s][i][j]){
            for(int t=0; t<n; ++t) if(!(s>>t&1)){
                if(abs(k[t]-k[j])>=B||dis(t,i)+dis(t,j)>=A) dp[s^(1<<t)][j][t]=1;
            }
        }
    }
    int res=1;
    for(int s=0; s<(1<<n); ++s) for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) if(dp[s][i][j]) res=max(res,__builtin_popcount(s));
    cout << res << "\n";
}
0