結果

問題 No.2375 watasou and hibit's baseball
ユーザー poyonpoyon
提出日時 2023-06-27 18:45:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,056 bytes
コンパイル時間 2,221 ms
コンパイル使用メモリ 209,368 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-22 17:35:03
合計ジャッジ時間 9,369 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 780 ms
4,380 KB
testcase_27 AC 1,186 ms
4,376 KB
testcase_28 AC 985 ms
4,376 KB
testcase_29 TLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 嘘解法 (TLE)
// DFS で全探索 + N 球投げられたら終了

#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
    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) { ok[a][a][b] = true; }
        }
    }
    // 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; }
            }
        }
    }

    int ans = 1;

    vector<bool> vis(N);
    for (int a = 0; a < N; a++) {
        for (int b = 0; b < N; b++) {
            if (not ok[a][a][b]) { continue; }
            auto dfs = [&](auto&& self, int i, int a, int b) -> void {
                ans = max(ans, i);
                if (i == N) {
                    cout << N << '\n';
                    exit(0);
                }
                for (int c = 0; c < N; c++) {
                    if (vis[c]) { continue; }
                    if (ok[a][b][c]) {
                        vis[c] = true;
                        self(self, i + 1, b, c);
                        vis[c] = false;
                    }
                }
            };

            vis[a] = vis[b] = true;
            dfs(dfs, 2, a, b);
            vis[a] = vis[b] = false;
        }
    }

    cout << ans << '\n';

    return 0;
}
0