QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#527750 | #7118. Closing Time | green_gold_dog# | 0 | 80ms | 26320kb | C++20 | 2.7kb | 2024-08-22 19:02:55 | 2024-08-22 19:02:55 |
Judging History
answer
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1'000'000'000'000'000'001;
vector<long long> dist(ll v, vector<vector<pair<ll, ll>>>& arr) {
vector<long long> ans(arr.size(), INF);
ans[v] = 0;
priority_queue<pair<long long, ll>, vector<pair<long long, ll>>, greater<pair<long long, ll>>> pq;
pq.emplace(0, v);
while (!pq.empty()) {
auto[d, nv] = pq.top();
pq.pop();
if (ans[nv] != d) {
continue;
}
for (auto[i, c] : arr[nv]) {
if (ans[i] > d + c) {
ans[i] = d + c;
pq.emplace(d + c, i);
}
}
}
return ans;
}
void dfs(ll v, vector<bool>& can, vector<bool>& used, vector<vector<pair<ll, ll>>>& arr) {
if (!can[v]) {
return;
}
used[v] = true;
for (auto[i, _] : arr[v]) {
if (!used[i]) {
dfs(i, can, used, arr);
}
}
}
int max_score(int n, int x, int y, long long k, vector<int> u, vector<int> v, vector<int> w) {
vector<vector<pair<ll, ll>>> arr(n);
for (ll i = 0; i < n - 1; i++) {
arr[u[i]].emplace_back(v[i], w[i]);
arr[v[i]].emplace_back(u[i], w[i]);
}
vector<long long> d1 = dist(x, arr), d2 = dist(y, arr);
vector<vector<bool>> cm1, cm2;
for (ll i = 0; i < (1 << n); i++) {
vector<bool> can(n, false);
for (ll j = 0; j < n; j++) {
if ((i >> j) & 1) {
can[j] = true;
}
}
vector<bool> used1(n, false), used2(n, false);
dfs(x, can, used1, arr);
dfs(y, can, used2, arr);
if (can == used1) {
cm1.push_back(can);
}
if (can == used2) {
cm2.push_back(can);
}
}
ll bans = 0;
for (auto i : cm1) {
for (auto j : cm2) {
long long nc = 0;
ll nans = 0;
for (ll k = 0; k < n; k++) {
if (i[k] && j[k]) {
nc += max(d1[k], d2[k]);
nans += 2;
} else {
if (i[k]) {
nc += d1[k];
nans++;
} else {
nc += d2[k];
nans++;
}
}
}
if (nc <= k) {
if (bans < nans) {
bans = nans;
}
}
}
}
return bans;
}
#ifdef LOCAL
int main()
{
int Q;
assert(1 == scanf("%d", &Q));
std::vector<int> N(Q), X(Q), Y(Q);
std::vector<long long> K(Q);
std::vector<std::vector<int>> U(Q), V(Q), W(Q);
for (int q = 0; q < Q; q++)
{
assert(4 == scanf("%d %d %d %lld", &N[q], &X[q], &Y[q], &K[q]));
U[q].resize(N[q] - 1);
V[q].resize(N[q] - 1);
W[q].resize(N[q] - 1);
for (int i = 0; i < N[q] - 1; ++i)
{
assert(3 == scanf("%d %d %d", &U[q][i], &V[q][i], &W[q][i]));
}
}
fclose(stdin);
std::vector<int> result(Q);
for (int q = 0; q < Q; q++)
{
result[q] = max_score(N[q], X[q], Y[q], K[q], U[q], V[q], W[q]);
}
for (int q = 0; q < Q; q++)
{
printf("%d\n", result[q]);
}
fclose(stdout);
return 0;
}
#endif
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 80ms
memory: 26320kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 200000 31011 61157 8517583098 31011 129396 964383 1655 129396 331139 1655 191487 566483 110385 191487 865248 43212 110385 542661 43212 81682 13766 81682 91774 546589 91774 124706 780638 124706 175650 118706 10421 175650 615314 10421 151953 436270 140430 151...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 0
result:
wrong answer 1st lines differ - on the 1st token, expected: '451', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #4:
score: 0
Wrong Answer
time: 41ms
memory: 3808kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 50 23 25 382806473 0 1 375710 1 2 898637 2 3 10402 3 4 536577 4 5 385023 5 6 71075 6 7 543368 7 8 301497 8 9 174394 9 10 711312 10 11 923006 11 12 675532 12 13 838667 13 14 565729 14 15 979816 15 16 862618 16 17 576015 17 18 177751 18 19 306989 19 20 881492...
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 50
result:
wrong answer 1st lines differ - on the 1st token, expected: '96', found: '50'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Wrong Answer
Test #36:
score: 9
Accepted
time: 0ms
memory: 4088kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 4 0 1 9 0 2 2 1 2 3 2 3 3
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 6
result:
ok
Test #37:
score: 0
Wrong Answer
time: 0ms
memory: 3800kb
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 4 0 1 8 0 2 2 1 2 3 2 3 100
output:
081ce3c351cbf526b37954b9ad30f2b531a7585c OK 0
result:
wrong answer 1st lines differ - on the 1st token, expected: '5', found: '0'
Subtask #6:
score: 0
Skipped
Dependency #2:
0%
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #4:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%