結果

問題 No.2375 watasou and hibit's baseball
ユーザー poyonpoyon
提出日時 2023-06-22 21:18:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,963 bytes
コンパイル時間 2,440 ms
コンパイル使用メモリ 211,712 KB
実行使用メモリ 14,648 KB
最終ジャッジ日時 2023-09-22 17:31:06
合計ジャッジ時間 8,744 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// 嘘解法 (TLE)
// 時間いっぱい乱択

#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);

    double TL_sec = 3.90;
    auto cur_time = []() -> double { return (double)clock() / CLOCKS_PER_SEC; };
    double start_time = cur_time();
    auto time_limit_over = [&]() -> bool { return TL_sec < cur_time() - start_time; };

    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<int> P(N);

    srand((unsigned)time(NULL));
    random_device seed_gen;
    mt19937 engine(seed_gen());

    while (not time_limit_over()) {
        iota(P.begin(), P.end(), 0);
        shuffle(P.begin(), P.end(), engine);

        int cnt = 1;
        if (ok[P[0]][P[0]][P[1]]) {
            cnt++;
            for (int i = 2; i < N; i++) {
                if (not ok[P[i - 2]][P[i - 1]][P[i]]) { break; }
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }

    cout << ans << '\n';

    return 0;
}
0