結果

問題 No.2375 watasou and hibit's baseball
ユーザー as277575as277575
提出日時 2023-07-07 23:29:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,449 bytes
コンパイル時間 1,840 ms
コンパイル使用メモリ 142,648 KB
実行使用メモリ 136,188 KB
最終ジャッジ日時 2023-09-29 01:13:21
合計ジャッジ時間 7,703 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <bit>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <set>
#include <string>

using namespace::std;

template<typename T, typename U>
ostream& operator<< (ostream& o, const pair<T, U>& p) {
  o << "<" << p.first << ", " << p.second << ">";
  return o;
}

template <typename T>
ostream& operator<< (ostream& o, const vector<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

template <typename T>
ostream& operator<< (ostream& o, const set<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

template <typename T>
ostream& operator<< (ostream& o, const deque<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

template <typename K, typename V>
ostream& operator<<(ostream& o, const unordered_map<K, V>& m) {
  o << "{";
  for (const auto& [k, v] : m)
    o << " " << k << ": " << v << ",";
  o << "}";
  return o;
}

template <typename T>
istream& operator>> (istream& i, vector<T>& v) {
  for (auto& x : v) i >> x;
  return i;
}

int main() {
  ios::sync_with_stdio(false);
  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];
  
  using State = pair<set<int>, deque<int>>;
  set<State> vis {};
  vector<State> q {{{}, {}}};
  while (q.size()) {
    State u = q.back();
    q.pop_back();
    if (vis.count(u)) continue;
    vis.insert(u);
    //cerr << "New State " << u << endl;
    for (int i = 0; i < n; ++i) {
      //cerr << "i " << i << endl;
      if (!u.first.count(i) && (
        u.first.size() == 0 ||
        (u.first.size() == 1 && a <= abs(x[i] - x[u.second.back()]) + abs(y[i] - y[u.second.back()]))
        || (u.first.size() >= 1 && b <= abs(k[i] - k[u.second.back()]))
        || (u.first.size() >= 2
          && a <= abs(x[i] - x[u.second.back()]) + abs(y[i] - y[u.second.back()]) +
            abs(x[i] - x[u.second[0]]) + abs(y[i] - y[u.second[0]])))) {
        
          State v = u;
          v.first.insert(i);
          if (v.second.size() > 2)
          v.second.pop_front();
          v.second.push_back(i);
          q.push_back(v);
            
        }
        
      }
        
  }
  unsigned long r = 0;
  for (const State& s : vis)
    r = max(r, s.first.size());
  cout << r << endl;
  return 0;
}

0