結果

問題 No.2375 watasou and hibit's baseball
ユーザー karinohitokarinohito
提出日時 2023-07-07 22:18:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 1,379 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 208,292 KB
実行使用メモリ 20,072 KB
最終ジャッジ日時 2023-09-28 23:40:57
合計ジャッジ時間 5,068 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 25 ms
10,900 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 117 ms
19,728 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 10 ms
7,048 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,432 KB
testcase_12 AC 41 ms
19,736 KB
testcase_13 AC 19 ms
10,920 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 9 ms
5,076 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 38 ms
19,708 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 39 ms
19,708 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 37 ms
20,072 KB
testcase_24 AC 38 ms
19,708 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 51 ms
19,788 KB
testcase_27 AC 56 ms
19,720 KB
testcase_28 AC 60 ms
19,708 KB
testcase_29 AC 66 ms
19,980 KB
testcase_30 AC 71 ms
19,800 KB
testcase_31 AC 64 ms
19,976 KB
testcase_32 AC 73 ms
19,980 KB
testcase_33 AC 60 ms
19,984 KB
testcase_34 AC 55 ms
20,012 KB
testcase_35 AC 72 ms
20,068 KB
testcase_36 AC 67 ms
20,060 KB
testcase_37 AC 53 ms
19,756 KB
testcase_38 AC 38 ms
19,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vll =vector<ll>;
using vvll =vector<vll>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vvvb=vector<vvb>;
#define rep(i,n) for(ll i=(ll)(0); i<(ll(n)); ++i)
#define all(x) (x).begin(), (x).end()

int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    vll X(N),Y(N),K(N);
    rep(i,N)cin>>X[i]>>Y[i]>>K[i];
    vvvb DP(1<<N,vvb(N,vb(N,0)));
    rep(i,N)DP[1<<i][i][i]=1;
    ll an=0;
    rep(bit,1<<N){
        rep(i,N){
            rep(j,N){
                if(DP[bit][i][j]){
                    ll cnt=0;
                    rep(k,N)if(bit&(1<<k))cnt++;
                    an=max(an,cnt);
                    rep(k,N){
                        if(bit&(1<<k))continue;
                        ll XS=abs(X[i]-X[k])+abs(Y[i]-Y[k]);
                        ll YS=abs(X[j]-X[k])+abs(Y[j]-Y[k]);
                        if(cnt==1){
                            if(A<=YS)DP[bit+(1<<k)][j][k]=true;
                        }
                        if(cnt>=1){
                            if(B<=abs(K[j]-K[k]))DP[bit+(1<<k)][j][k]=1;
                        }
                        if(cnt>=2){
                            if(A<=XS+YS)DP[bit+(1<<k)][j][k]=1;
                        }
                        
                    }
                }
            }
            
        }
    }
    cout<<an<<endl;
}
0