結果

問題 No.2375 watasou and hibit's baseball
ユーザー 👑 hitonanodehitonanode
提出日時 2023-07-14 01:01:54
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,349 bytes
コンパイル時間 1,140 ms
コンパイル使用メモリ 96,416 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-13 13:13:37
合計ジャッジ時間 4,045 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 9 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 83 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 11 ms
4,348 KB
testcase_13 AC 5 ms
4,352 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 5 ms
4,352 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 9 ms
4,352 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 9 ms
4,348 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 9 ms
4,352 KB
testcase_24 AC 9 ms
4,348 KB
testcase_25 AC 1 ms
4,352 KB
testcase_26 AC 18 ms
4,348 KB
testcase_27 AC 21 ms
4,348 KB
testcase_28 AC 25 ms
4,480 KB
testcase_29 AC 30 ms
4,348 KB
testcase_30 AC 34 ms
4,348 KB
testcase_31 AC 31 ms
4,348 KB
testcase_32 AC 40 ms
4,348 KB
testcase_33 AC 24 ms
4,352 KB
testcase_34 AC 20 ms
4,352 KB
testcase_35 AC 36 ms
4,352 KB
testcase_36 AC 30 ms
4,352 KB
testcase_37 AC 21 ms
4,348 KB
testcase_38 AC 9 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main() {
    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.at(i) >> Y.at(i) >> K.at(i);
    }

    vector dp(N, vector(N, vector<bool>(1 << N)));
    for (int i = 0; i < N; ++i) dp.at(i).at(i).at(1 << i) = true;

    int ret = 1;

    for (int S = 0; S < 1 << N; ++S) {
        for (int pre = 0; pre < N; ++pre) {
            for (int prepre = 0; prepre < N; ++prepre) {
                if (!dp.at(prepre).at(pre).at(S)) continue;
                for (int nxt = 0; nxt < N; ++nxt) {
                    if (S & (1 << nxt)) continue;
                    bool good = false;
                    if (abs(K.at(nxt) - K.at(pre)) >= B) good = true;
                    int dist = abs(X.at(nxt) - X.at(pre)) + abs(Y.at(nxt) - Y.at(pre));
                    if (pre != prepre) {
                        dist += abs(X.at(nxt) - X.at(prepre)) + abs(Y.at(nxt) - Y.at(prepre));
                    }
                    if (dist >= A) good = true;
                    if (good) {
                        dp.at(pre).at(nxt).at(S | (1 << nxt)) = 1;
                        ret = max(ret, __builtin_popcount(S | (1 << nxt)));
                    }
                }
            }
        }
    }
    cout << ret << '\n';
}
0