結果

問題 No.2375 watasou and hibit's baseball
ユーザー pointNpointN
提出日時 2023-07-12 00:04:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 1,646 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 137,872 KB
実行使用メモリ 37,860 KB
最終ジャッジ日時 2023-10-11 14:58:05
合計ジャッジ時間 6,040 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 29 ms
17,560 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 116 ms
37,776 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 11 ms
10,032 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 3 ms
4,800 KB
testcase_12 AC 53 ms
37,772 KB
testcase_13 AC 23 ms
17,664 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 9 ms
6,068 KB
testcase_16 AC 5 ms
4,596 KB
testcase_17 AC 50 ms
37,712 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 AC 4 ms
4,644 KB
testcase_21 AC 49 ms
37,680 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 49 ms
37,660 KB
testcase_24 AC 49 ms
37,660 KB
testcase_25 AC 2 ms
4,352 KB
testcase_26 AC 60 ms
37,860 KB
testcase_27 AC 64 ms
37,716 KB
testcase_28 AC 67 ms
37,680 KB
testcase_29 AC 70 ms
37,664 KB
testcase_30 AC 79 ms
37,656 KB
testcase_31 AC 72 ms
37,668 KB
testcase_32 AC 79 ms
37,716 KB
testcase_33 AC 67 ms
37,664 KB
testcase_34 AC 63 ms
37,736 KB
testcase_35 AC 77 ms
37,772 KB
testcase_36 AC 71 ms
37,668 KB
testcase_37 AC 62 ms
37,668 KB
testcase_38 AC 49 ms
37,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N,A,B; cin >> N >> A >> B;
  vector<int> X(N),Y(N),K(N);
  rep(i,N) cin >> X[i] >> Y[i] >> K[i];
  vector dp(1<<N,vector(N,vector<ll>(N,0)));
  rep(i,N){
    dp[1<<i][0][i] = 1;
  }
  rep(i,1<<N){
    rep(j,N){
      rep(k,N){
        if(dp[i][j][k]==0) continue;
        int p = __builtin_popcount(i);
        rep(l,N){
          if(i&(1<<l)) continue;
          if(A<=abs(X[k]-X[l])+abs(Y[k]-Y[l])) dp[i+(1<<l)][k][l] = 1;
          if(B<=abs(K[k]-K[l])) dp[i+(1<<l)][k][l] = 1;
          if(p>=2){
            if(A<=abs(X[k]-X[l])+abs(Y[k]-Y[l])+abs(X[j]-X[l])+abs(Y[j]-Y[l])) dp[i+(1<<l)][k][l] = 1;
          }
        }
      }
    }
  }
  int ans = 0;
  rep(i,1<<N){
    rep(j,N){
      rep(k,N){
        if(dp[i][j][k]) chmax(ans,__builtin_popcount(i));
      }
    }
  }
  cout << ans << endl;
  return 0;
};
0