結果
問題 | No.2375 watasou and hibit's baseball |
ユーザー |
![]() |
提出日時 | 2023-07-07 23:25:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 109 ms / 2,000 ms |
コード長 | 1,372 bytes |
コンパイル時間 | 4,078 ms |
コンパイル使用メモリ | 255,332 KB |
最終ジャッジ日時 | 2025-02-15 08:35:58 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#include<bits/stdc++.h>#include<atcoder/all>using namespace std;using namespace atcoder;typedef modint998244353 mint;typedef long long ll;#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)template <typename T> bool chmin(T &a, const T &b) {if (a <= b) return false;a = b;return true;}template <typename T> bool chmax(T &a, const T &b) {if (a >= b) return false;a = b;return true;}bool hav[15];ll x[15], y[15], k[15];ll a, b;int n;vector<int> tr;int tar = 0;ll dist(int i, int j){if (i == n) return 0;if (j == n) return 1e18;return abs(x[i] - x[j]) + abs(y[i] - y[j]);}ll kdist(int i, int j){if (i == n) return 1e18;if (j == n) return 1e18;return abs(k[i] - k[j]);}int main(){cin >> n >> a >> b;rep(i,0,n){cin >> x[i] >> y[i] >> k[i];}vector dp(1<<n, vector(n+1, vector<bool>(n+1)));dp[0][n][n] = true;rep(i,0,1<<n){rep(j,0,n+1){rep(k,0,n+1){if (!dp[i][j][k]) continue;rep(l,0,n){if ((i >> l & 1) == 0){if (a <= dist(l, k) + dist(j, l) || b <= kdist(l, k)){dp[i|(1<<l)][k][l] = true;}}}}}}int ans = 0;rep(i,0,1<<n){int val = __builtin_popcount(i);rep(j,0,n+1){rep(k,0,n+1){if (dp[i][j][k]) chmax(ans, val);}}}cout << ans << endl;}