結果

問題 No.2375 watasou and hibit's baseball
ユーザー SSRSSSRS
提出日時 2023-07-07 21:41:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,213 bytes
コンパイル時間 1,793 ms
コンパイル使用メモリ 177,356 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-28 22:42:31
合計ジャッジ時間 3,470 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 3 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 6 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 20 ms
4,380 KB
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
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[i] >> Y[i] >> K[i];
  }
  vector<vector<int>> d(N, vector<int>(N));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      d[i][j] = abs(X[i] - X[j]) + abs(Y[i] - Y[j]);
    }
  }
  vector<vector<vector<bool>>> dp(N, vector<vector<bool>>(N, vector<bool>(1 << N, false)));
  dp[0][0][0] = true;
  int ans = 0;
  for (int i = 0; i < (1 << N); i++){
    for (int j = 0; j < N; j++){
      for (int k = 0; k < N; k++){
        if (dp[j][k][i]){
          for (int l = 0; l < N; l++){
            if ((i >> l & 1) == 0){
              int c = __builtin_popcount(i);
              bool ok = false;
              if (c == 0){
                ok = true;
              } else if (c == 1){
                ok = d[k][l] >= A;
              } else {
                ok = abs(K[k] - K[l]) >= B || d[j][l] + d[k][l] >= A;
              }
              if (ok){
                ans = max(ans, c + 1);
                dp[k][l][i | (1 << l)] = true;
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}
0