結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 79 ms
19,880 KB
testcase_07 WA -
testcase_08 AC 10 ms
6,700 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 6 ms
5,008 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 44 ms
20,012 KB
testcase_24 AC 44 ms
19,960 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 59 ms
19,900 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 54 ms
19,944 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 53 ms
19,948 KB
testcase_38 AC 46 ms
19,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 嘘解法
// マンハッタン距離で X しか使っていない

#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 d = abs(X[c] - X[a]) + abs(X[c] - X[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 d = abs(X[b] - X[a]);
            int v = abs(K[b] - K[a]);
            if (d >= A || 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