結果

問題 No.2375 watasou and hibit's baseball
ユーザー momoyuumomoyuu
提出日時 2023-07-08 01:38:07
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 1,622 bytes
コンパイル時間 1,003 ms
コンパイル使用メモリ 106,648 KB
実行使用メモリ 17,864 KB
最終ジャッジ日時 2023-09-29 03:11:27
合計ジャッジ時間 3,610 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 14 ms
11,532 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 88 ms
17,628 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 6 ms
7,248 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 17 ms
17,708 KB
testcase_13 AC 8 ms
11,532 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 8 ms
5,156 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 14 ms
17,744 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 14 ms
17,624 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 14 ms
17,560 KB
testcase_24 AC 14 ms
17,596 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 25 ms
17,624 KB
testcase_27 AC 29 ms
17,680 KB
testcase_28 AC 33 ms
17,624 KB
testcase_29 AC 37 ms
17,800 KB
testcase_30 AC 43 ms
17,804 KB
testcase_31 AC 39 ms
17,800 KB
testcase_32 AC 48 ms
17,552 KB
testcase_33 AC 32 ms
17,740 KB
testcase_34 AC 27 ms
17,628 KB
testcase_35 AC 43 ms
17,692 KB
testcase_36 AC 36 ms
17,864 KB
testcase_37 AC 29 ms
17,796 KB
testcase_38 AC 15 ms
17,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<cassert>
using namespace std;
using ll = long long;

int dp[1<<14][15][15];
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    vector<int> x(n),y(n),k(n);
    for(int i = 0;i<n;i++) cin>>x[i]>>y[i]>>k[i];
    for(int i = 0;i<1<<n;i++) for(int j = 0;j<n;j++) for(int l = 0;l<n;l++) dp[i][j][l] = 0;
    dp[0][0][0] = 1;
    for(int i = 1;i<1<<n;i++){
        if(__builtin_popcount(i)==1){
            int ni = 0;
            for(int j = 0;j<n;j++) if(i>>j&1) ni = j;
            for(int j = 0;j<n;j++) dp[i][j][ni] = 1;
        }
        for(int j = 0;j<n;j++){
            for(int l = 0;l<n;l++){
                if(dp[i][j][l]==0) continue;
                for(int m = 0;m<n;m++){
                    if(i>>m&1) continue;
                    int nxt = i | 1<<m;
                    int cnt = __builtin_popcount(nxt);
                    assert(cnt>=2);
                    bool ok = false;
                    if(abs(k[l]-k[m])>=b) dp[nxt][l][m] = 1;
                    if(cnt==2){
                        if(a<=abs(x[l]-x[m])+abs(y[l]-y[m])) dp[nxt][l][m] = 1;
                    }
                    if(cnt>=3){
                        if(a<=abs(x[l]-x[m])+abs(y[l]-y[m])+abs(x[j]-x[m])+abs(y[j]-y[m]))
                            dp[nxt][l][m] = 1;
                    }
                }
            }
        }
    
    }
    int ans = 0;
    for(int i = 0;i<1<<n;i++) for(int j = 0;j<n;j++) for(int l = 0;l<n;l++) if(dp[i][j][l]) ans = max(ans,__builtin_popcount(i));
    cout<<ans<<endl;
        

}

0