QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#708209 | #4781. 完美的集合 | NineSuns | 0 | 19ms | 334088kb | C++14 | 1.7kb | 2024-11-03 20:23:16 | 2024-11-03 20:23:18 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back
#define pil pair <int, ll>
#define LL __int128
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 65, S = 10005;
const ll mod = 11920928955078125, inf = 0x3f3f3f3f3f3f3f3f;
int n, m, c, mk[N][N];
ll M, w[N], v[N], k, dis[N][N], f[N][N][S], g[S];
vector <pil> e[N];
void dfs (int rt, int p, int fa) {
for (auto i : e[p]) {
if (i.fi == fa) continue;
dis[rt][i.fi] = dis[rt][p]+i.se; dfs(rt, i.fi, p);
}
}
vector <int> td;
void dp (int p, int fa) {
if (mk[p][fa]) return;
mk[p][fa] = 1;
if (w[p] <= m) f[p][fa][w[p]] = v[p];
for (auto i : e[p]) {
dp(i.fi, p);
memset(g, -0x3f, sizeof g);
td.clear();
for (int j = 0;j <= m;j++) if (f[i.fi][p][j] >= 0) td.pb(j);
for (int j = 0;j <= m;j++) {
if (f[p][fa][j] < 0) continue;
for (int z : td) if (j+z <= m) g[j+z] = max(g[j+z], f[i.fi][p][z]+f[p][fa][j]);
}
memcpy(f[p][fa], g, sizeof g);
}
f[p][fa][0] = 0;
}
void solve () {
memset(f, -0x3f, sizeof f);
cin >> n >> m >> k >> M;
for (int i = 1;i <= n;i++) cin >> w[i];
for (int i = 1;i <= n;i++) cin >> v[i];
for (int i = 1;i < n;i++) {
int x, y; ll c; cin >> x >> y >> c;
e[x].pb({y, c}); e[y].pb({x, c});
}
for (int i = 1;i <= n;i++) dfs(i, i, 0);
for (int i = 1;i <= n;i++) dp(i, 0);
ll ans = -inf;
for (int i = 1;i <= n;i++) for (int j = 0;j <= m;j++) ans = max(ans, f[i][0][j]);
cout << ans;
}
signed main () {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int T = 1;
while (T--) solve();
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 334036kb
input:
16 109 1 4025082 46 68 46 1 46 67 111 1 156 1 45 45 1 45 45 45 8525 12789 8526 0 8526 12788 954 0 6 0 8525 8526 0 8525 8526 8526 1 2 290 1 3 188 1 4 420 1 5 6 2 6 29 1 7 643 1 8 461 4 9 468 1 10 228 5 11 428 2 12 71 4 13 290 1 14 957 2 15 955 4 16 549
output:
17051
result:
wrong answer 1st numbers differ - expected: '25', found: '17051'
Subtask #2:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 15ms
memory: 333928kb
input:
40 816 1 285 46 124 125 137 90 33 15 73 67 41 134 106 3 163 152 151 14 77 157 82 40 9 151 148 60 60 163 71 40 134 152 145 70 59 26 64 94 38 158 57 2 2 1 1 1 1 3 3 1 1 3 3 1 3 1 3 2 1 3 3 1 1 2 2 3 2 1 2 1 2 2 1 3 3 3 1 1 1 3 3 1 2 20 1 3 26 2 4 14 3 5 25 1 6 17 4 7 49 1 8 37 1 9 50 2 10 52 4 11 55 2...
output:
31
result:
wrong answer 1st numbers differ - expected: '3', found: '31'
Subtask #3:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 19ms
memory: 334088kb
input:
60 2 14 266401688520 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 712303980 712303980 712303979 712303980 712303980 712303980 712303980 712303980 712303980 712303980 712303980 712303980 712303980 712303980 712303980 712303980...
output:
1424607960
result:
wrong answer 1st numbers differ - expected: '120', found: '1424607960'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%