結果

問題 No.2375 watasou and hibit's baseball
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-07-07 23:19:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,514 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 205,988 KB
実行使用メモリ 54,308 KB
最終ジャッジ日時 2023-09-29 01:04:08
合計ジャッジ時間 6,786 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 72 ms
23,368 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 144 ms
53,992 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 24 ms
12,708 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 6 ms
5,320 KB
testcase_12 AC 137 ms
54,300 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 16 ms
7,736 KB
testcase_16 AC 6 ms
5,496 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 6 ms
5,492 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 122 ms
54,112 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 153 ms
54,072 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 173 ms
54,004 KB
testcase_34 WA -
testcase_35 AC 142 ms
54,132 KB
testcase_36 AC 129 ms
54,124 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){

    int N, A, B, M, K, d;
    cin >> N >> A >> B;
    M = 1<<(N+1);
    vector<int> X(N+1), Y(N+1), Z(N+1);
    for (int i=1; i<=N; i++) cin >> X[i] >> Y[i] >> Z[i];
    vector<vector<vector<int>>> dp(M, vector(N+1, vector<int>(N+1)));

    for (int i=1; i<=N; i++) dp[1<<i][i][0] = 1;

    for (int i=1; i<M; i++){
        K = __builtin_popcount(i);
        if (K == 1){
            for (int j=1; j<=N; j++){
                if (1<<j & i) continue;
                for (int k=1; k<=N; k++){
                    if (j == k) continue;
                    if (dp[i][k][0] && (B<=abs(Z[j]-Z[k]) || A<=abs(X[j]-X[k])+abs(Y[j]-Y[k]))) dp[i|1<<j][j][k] = 1;
                }
            }
        }
        else{
            for (int j=1; j<=N; j++){
                if (1<<j & i) continue;
                for (int k=1; k<=N; k++){
                    bool f=0;
                    if (j == k) continue;
                    if (B>abs(Z[j]-Z[k])) f=1;
                    for (int l=1; l<=N; l++){
                        if (dp[i][k][l] && (f || A<=abs(X[j]-X[k])+abs(Y[j]-Y[k])+abs(X[j]-X[l])+abs(Y[j]-Y[l]))) dp[i|1<<j][j][k] = 1;
                    }
                }
            }
        }
    }


    int ans=0;
    for (int i=0; i<M; i++){
        for (int j=0; j<=N; j++){
            for (int k=0; k<=N; k++) if (dp[i][j][k]) ans = max(ans, __builtin_popcount(i));
        }
    }

    cout << ans << endl;

    return 0;
}
0