結果

問題 No.2375 watasou and hibit's baseball
ユーザー KowerKoint2010KowerKoint2010
提出日時 2023-07-01 14:22:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 1,141 bytes
コンパイル時間 2,215 ms
コンパイル使用メモリ 205,740 KB
実行使用メモリ 28,940 KB
最終ジャッジ日時 2023-09-22 17:40:13
合計ジャッジ時間 4,436 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 22 ms
13,516 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 95 ms
28,940 KB
testcase_07 AC 1 ms
4,500 KB
testcase_08 AC 8 ms
8,236 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,396 KB
testcase_12 AC 39 ms
28,780 KB
testcase_13 AC 16 ms
13,400 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 8 ms
5,744 KB
testcase_16 AC 4 ms
4,456 KB
testcase_17 AC 37 ms
28,520 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 37 ms
28,460 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 36 ms
28,776 KB
testcase_24 AC 35 ms
28,504 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 46 ms
28,932 KB
testcase_27 AC 51 ms
28,488 KB
testcase_28 AC 53 ms
28,500 KB
testcase_29 AC 57 ms
28,512 KB
testcase_30 AC 60 ms
28,428 KB
testcase_31 AC 55 ms
28,452 KB
testcase_32 AC 63 ms
28,936 KB
testcase_33 AC 52 ms
28,776 KB
testcase_34 AC 49 ms
28,444 KB
testcase_35 AC 62 ms
28,780 KB
testcase_36 AC 56 ms
28,500 KB
testcase_37 AC 50 ms
28,448 KB
testcase_38 AC 36 ms
28,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n, a, b; cin >> n >> a >> b;
    vector<int> x(n), y(n), s(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> s[i];
    vector dp(vector(1<<n, vector(n+1, vector<int>(n+1))));
    dp[0][n][n] = 1;
    int ans = 0;
    for(int st = 0; st < (1<<n); st++) {
        for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) {
            if(!dp[st][i][j]) continue;
            for(int k = 0; k < n; k++) {
                if(st >> k & 1) continue;
                bool strike = false;
                if(j == n) strike |= true;
                else if(i == n) {
                    strike |= a <= abs(x[k]-x[j]) + abs(y[k]-y[j]);
                } else {
                    strike |= a <= abs(x[k]-x[j]) + abs(y[k]-y[j]) + abs(x[k]-x[i]) + abs(y[k]-y[i]);
                }
                if(j < n) strike |= b <= abs(s[k]-s[j]);
                if(strike) {
                    dp[st|(1<<k)][j][k] = 1;
                    ans = max(ans, __builtin_popcount(st|(1<<k)));
                }
            }
        }
    }
    cout << ans << endl;
}
0