結果

問題 No.2375 watasou and hibit's baseball
ユーザー momoyuumomoyuu
提出日時 2023-07-08 01:30:19
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,578 bytes
コンパイル時間 1,114 ms
コンパイル使用メモリ 106,192 KB
実行使用メモリ 18,072 KB
最終ジャッジ日時 2023-09-29 03:02:08
合計ジャッジ時間 4,864 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 17 ms
11,512 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 92 ms
17,764 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 AC 28 ms
17,712 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 8 ms
5,144 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 41 ms
17,740 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 49 ms
17,704 KB
testcase_34 WA -
testcase_35 AC 49 ms
17,752 KB
testcase_36 AC 48 ms
17,904 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

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){
            for(int j = 0;j<n;j++) dp[i][j][i] = 1;
        }
        for(int j = 0;j<n;j++){
            for(int l = 0;l<n;l++){
                if(j==l) continue;
                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