結果
| 問題 |
No.2375 watasou and hibit's baseball
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2023-07-14 01:01:54 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 2,000 ms |
| コード長 | 1,349 bytes |
| コンパイル時間 | 1,334 ms |
| コンパイル使用メモリ | 97,072 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 10:03:17 |
| 合計ジャッジ時間 | 2,922 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#include <iostream>
#include <vector>
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.at(i) >> Y.at(i) >> K.at(i);
}
vector dp(N, vector(N, vector<bool>(1 << N)));
for (int i = 0; i < N; ++i) dp.at(i).at(i).at(1 << i) = true;
int ret = 1;
for (int S = 0; S < 1 << N; ++S) {
for (int pre = 0; pre < N; ++pre) {
for (int prepre = 0; prepre < N; ++prepre) {
if (!dp.at(prepre).at(pre).at(S)) continue;
for (int nxt = 0; nxt < N; ++nxt) {
if (S & (1 << nxt)) continue;
bool good = false;
if (abs(K.at(nxt) - K.at(pre)) >= B) good = true;
int dist = abs(X.at(nxt) - X.at(pre)) + abs(Y.at(nxt) - Y.at(pre));
if (pre != prepre) {
dist += abs(X.at(nxt) - X.at(prepre)) + abs(Y.at(nxt) - Y.at(prepre));
}
if (dist >= A) good = true;
if (good) {
dp.at(pre).at(nxt).at(S | (1 << nxt)) = 1;
ret = max(ret, __builtin_popcount(S | (1 << nxt)));
}
}
}
}
}
cout << ret << '\n';
}
hitonanode