結果

問題 No.2375 watasou and hibit's baseball
ユーザー t98slidert98slider
提出日時 2023-07-07 22:06:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,865 bytes
コンパイル時間 1,861 ms
コンパイル使用メモリ 179,440 KB
実行使用メモリ 20,196 KB
最終ジャッジ日時 2023-09-28 23:25:09
合計ジャッジ時間 4,895 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 58 ms
19,872 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 9 ms
6,672 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 43 ms
20,012 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 7 ms
5,132 KB
testcase_16 AC 4 ms
4,412 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 38 ms
19,936 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 39 ms
19,868 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 47 ms
19,852 KB
testcase_29 WA -
testcase_30 AC 50 ms
19,868 KB
testcase_31 AC 45 ms
19,992 KB
testcase_32 AC 53 ms
19,928 KB
testcase_33 WA -
testcase_34 AC 41 ms
20,112 KB
testcase_35 WA -
testcase_36 AC 48 ms
19,872 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, A, B;
    cin >> n >> A >> B;
    vector<tuple<int,int,int>> a(n);
    for(int i = 0; i < n; i++){
        int x, y, k;
        cin >> x >> y >> k;
        a[i] = make_tuple(x, y, k);
    }

    vector<vector<vector<bool>>> dp(1 << n, vector<vector<bool>>(n, vector<bool>(n)));
    for(int i = 0; i < n; i++) dp[1 << i][i][0] = true;
    
    auto f = [&](int i, int j, int k){
        int x1, y1, k1;
        int x2, y2, k2;
        int x3, y3, k3;
        tie(x1, y1, k1) = a[i];
        tie(x2, y2, k2) = a[j];
        tie(x3, y3, k3) = a[k];
        if(abs(k1 - k2) >= B) return true;
        if(abs(x1 - x2) + abs(y1 - y2) + abs(y1 - y3) + abs(x1 - x3) >= A) return true;
        return false;
    };

    int ans = 1;
    for(int i = 0; i < (1 << n); i++){
        int b = __builtin_popcount(i);
        if(b == 1){
            for(int j = 0; j < n; j++){
                if(!dp[i][j][0]) continue;
                int x1, y1, k1;
                tie(x1, y1, k1) = a[j];
                for(int k = 0; k < n; k++){
                    int x2, y2, k2;
                    tie(x2, y2, k2) = a[k];
                    if(i == j) continue;
                    if(A <= abs(x1 - x2) + abs(y1 - y2) || B <= abs(k1 - k2)) dp[i | (1 << k)][k][j] = true;
                }
            }
        }else{
            for(int j = 0; j < n; j++){
                if(~i >> j & 1) continue;
                for(int k = 0; k < n; k++){
                    if(!dp[i][j][k]) continue;
                    ans = max(ans, b);
                    for(int l = 0; l < n; l++){
                        if(f(l, k, j)) dp[i | (1 << l)][l][k] = true;
                    }
                }
            }
        }
    }
    cout << ans << '\n';
}
0