結果

問題 No.2375 watasou and hibit's baseball
ユーザー poyonpoyon
提出日時 2023-06-27 19:20:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,296 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 208,816 KB
実行使用メモリ 20,088 KB
最終ジャッジ日時 2023-09-22 17:36:15
合計ジャッジ時間 4,689 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 26 ms
10,892 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 94 ms
19,836 KB
testcase_07 WA -
testcase_08 AC 11 ms
6,856 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 48 ms
20,088 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 8 ms
5,004 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 46 ms
19,888 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 46 ms
19,816 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 47 ms
19,888 KB
testcase_24 AC 46 ms
19,908 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 54 ms
19,960 KB
testcase_27 AC 58 ms
20,008 KB
testcase_28 AC 61 ms
19,936 KB
testcase_29 AC 63 ms
19,912 KB
testcase_30 AC 68 ms
20,052 KB
testcase_31 AC 64 ms
20,088 KB
testcase_32 AC 69 ms
19,948 KB
testcase_33 AC 61 ms
19,908 KB
testcase_34 AC 58 ms
19,948 KB
testcase_35 AC 69 ms
19,884 KB
testcase_36 AC 65 ms
19,916 KB
testcase_37 WA -
testcase_38 AC 46 ms
19,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 嘘解法
// 条件 2 を使っていない
// → $j = 2$ かつ $A \leq dist(S_{j}, S_{j-1})$

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    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]; }

    vector<vector<vector<bool>>> ok(N, vector<vector<bool>>(N, vector<bool>(N)));
    // a -> b -> c
    for (int a = 0; a < N; a++) {
        for (int b = 0; b < N; b++) {
            for (int c = 0; c < N; c++) {
                if (a == b || a == c || b == c) { continue; }
                int d = abs(X[c] - X[a]) + abs(Y[c] - Y[a]) + abs(X[c] - X[b]) + abs(Y[c] - Y[b]);
                int v = abs(K[c] - K[b]);
                if (d >= A || v >= B) { ok[a][b][c] = true; }
            }
        }
    }

    vector<vector<vector<bool>>> dp(1 << N, vector<vector<bool>>(N, vector<bool>(N)));
    // a -> b
    for (int a = 0; a < N; a++) {
        for (int b = 0; b < N; b++) {
            if (a == b) { continue; }
            // int d = abs(X[b] - X[a]) + abs(Y[b] - Y[a]);
            int v = abs(K[b] - K[a]);
            // if (d >= A || v >= B) { dp[(1 << a) + (1 << b)][a][b] = true; }
            if (v >= B) { dp[(1 << a) + (1 << b)][a][b] = true; }
        }
    }
    for (int S = 1; S < (1 << N); S++) {
        for (int a = 0; a < N; a++) {
            if (((S >> a) & 1) == 0) { continue; }
            for (int b = 0; b < N; b++) {
                if (((S >> b) & 1) == 0) { continue; }
                if (not dp[S][a][b]) { continue; }
                for (int c = 0; c < N; c++) {
                    if (((S >> c) & 1) == 1) { continue; }
                    if (not ok[a][b][c]) { continue; }
                    dp[S + (1 << c)][b][c] = true;
                }
            }
        }
    }

    int ans = 1;
    for (int S = 1; S < (1 << N); S++) {
        for (int a = 0; a < N; a++) {
            for (int b = 0; b < N; b++) {
                if (dp[S][a][b]) {
                    int pcnt = __builtin_popcount(S);
                    ans = max(ans, pcnt);
                }
            }
        }
    }
    cout << ans << '\n';

    return 0;
}
0