結果

問題 No.2375 watasou and hibit's baseball
ユーザー hiro71687khiro71687k
提出日時 2023-07-12 18:09:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 1,866 bytes
コンパイル時間 2,185 ms
コンパイル使用メモリ 207,948 KB
実行使用メモリ 37,944 KB
最終ジャッジ日時 2023-10-12 08:27:08
合計ジャッジ時間 6,204 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 27 ms
17,568 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 104 ms
37,644 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 11 ms
10,208 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 3 ms
4,840 KB
testcase_12 AC 49 ms
37,640 KB
testcase_13 AC 21 ms
17,572 KB
testcase_14 AC 1 ms
4,368 KB
testcase_15 AC 8 ms
6,272 KB
testcase_16 AC 4 ms
4,600 KB
testcase_17 AC 47 ms
37,640 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 3 ms
4,608 KB
testcase_21 AC 48 ms
37,756 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 48 ms
37,736 KB
testcase_24 AC 48 ms
37,688 KB
testcase_25 AC 1 ms
4,352 KB
testcase_26 AC 57 ms
37,784 KB
testcase_27 AC 60 ms
37,732 KB
testcase_28 AC 63 ms
37,668 KB
testcase_29 AC 65 ms
37,664 KB
testcase_30 AC 70 ms
37,668 KB
testcase_31 AC 67 ms
37,640 KB
testcase_32 AC 72 ms
37,640 KB
testcase_33 AC 62 ms
37,688 KB
testcase_34 AC 58 ms
37,720 KB
testcase_35 AC 69 ms
37,636 KB
testcase_36 AC 65 ms
37,740 KB
testcase_37 AC 57 ms
37,944 KB
testcase_38 AC 47 ms
37,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=998244353;
ld inf=10000999999999900;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll>x(n),y(n),kk(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> kk[i];
    }
    vector<ll>two(20,1);
    for (ll i = 1; i < 20; i++)
    {
        two[i]=two[i-1]*2;
    }
    vector<vector<vector<ll>>>dp(two[n],vector<vector<ll>>(n,vector<ll>(n,-1)));
    ll ans=1;
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j < n; j++)
        {
            if (i==j)
            {
                continue;
            }
            if (abs(x[i]-x[j])+abs(y[i]-y[j])>=a||abs(kk[i]-kk[j])>=b)
            {
                dp[two[i]+two[j]][i][j]=2;
            }
        }
    }
    for (ll i = 1; i < two[n]; i++)
    {
        for (ll j = 0; j < n; j++)
        {
            for (ll k = 0; k < n; k++)
            {
                if (dp[i][j][k]==-1)
                {
                    continue;
                }
                for (ll l = 0; l < n; l++)
                {
                    if (i&two[l])
                    {
                        continue;
                    }
                    if (abs(kk[l]-kk[k])>=b)
                    {
                        dp[i+two[l]][k][l]=dp[i][j][k]+1;
                    }
                    if (abs(x[l]-x[j])+abs(y[l]-y[j])+abs(x[l]-x[k])+abs(y[l]-y[k])>=a)
                    {
                        dp[i+two[l]][k][l]=dp[i][j][k]+1;
                    }
                }
            }
        }
    }
    for (ll i = 0; i < two[n]; i++)
    {
        for (ll k = 0; k < n; k++)
        {
            for (ll j = 0; j < n; j++)
            {
                ans=max(ans,dp[i][k][j]);
            }
        }
    }
    cout << ans << endl;
}
0