QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#533913 | #1490. Road Closures | Nika533 | 0 | 102ms | 7340kb | C++17 | 1.2kb | 2024-08-26 16:44:07 | 2024-08-26 16:44:08 |
Judging History
answer
#include "roads.h"
#include <bits/stdc++.h>
using namespace std;
const int NN=1e5+5;
int n;
long long dp[NN][2];
vector<pair<int,int>> g[NN];
void dfs(int x, int p, int k) {
vector<long long> v; long long val=0;
for (auto AA:g[x]) {
int y=AA.first,w=AA.second;
if (y==p) continue;
dfs(y,x,k);
val+=dp[y][0]; v.push_back(w-max(0ll,dp[y][0]-dp[y][1]));
}
int sz=v.size();
sort(v.begin(),v.end());
dp[x][0]=val; dp[x][1]=val;
if (x==0) {
for (int i=sz-1; i>=k; i--) dp[x][0]+=v[i];
for (int i=sz-1; i>=k+1; i--) dp[x][1]+=v[i];
}
else {
if (k==0) dp[x][0]=1e15;
else for (int i=sz-1; i>=k-1; i--) dp[x][0]+=v[i];
for (int i=sz-1; i>=k; i--) dp[x][1]+=v[i];
}
}
long long solve(int k) {
dfs(0,0,k);
// for (int i=0; i<n; i++) cout<<i<<" "<<dp[i][1]<<" "<<dp[i][0]<<endl;
return dp[0][0];
}
vector<long long> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) {
vector<long long> ans(N,0); n=N;
for (int i=0; i<N; i++) {
g[U[i]].emplace_back(V[i],W[i]);
g[V[i]].emplace_back(U[i],W[i]);
}
for (int k=0; k<n; k++) ans[k]=solve(k);
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 102ms
memory: 7340kb
input:
c10234cabdfd6eae47773fb6f163e0350fc797e1 2000 0 559 717769868 0 237 766447943 0 122 517523402 0 1779 560381127 0 1477 566064983 0 67 303410673 0 1869 605544497 0 1769 774963386 0 457 469996896 0 201 995323973 0 1694 885366346 0 1547 362843462 0 55 947026157 0 1302 448837561 0 733 673028958 0 1139 65...
output:
064bde9ff69ddc34b3b45c2d26d58873d85290d3 OK 1239932930636 1239682184182 1239431270838 1239180012239 1238928038373 1238675835123 1238423518093 1238171010206 1237917899082 1237664443108 1237410861561 1237156168478 1236901362055 1236646419601 1236391045380 1236135093751 1235878071424 1235620658273 1235...
result:
wrong answer 3rd lines differ - expected: '1239932930636 1238933034699 12...752918397 501659798 250746454 0', found: '1239932930636 1239682184182 12...99119332 1999656232 999895937 0'
Subtask #2:
score: 0
Time Limit Exceeded
Test #19:
score: 7
Accepted
time: 0ms
memory: 6796kb
input:
c10234cabdfd6eae47773fb6f163e0350fc797e1 2 0 1 4
output:
064bde9ff69ddc34b3b45c2d26d58873d85290d3 OK 4 0
result:
ok 3 lines
Test #20:
score: 0
Time Limit Exceeded
input:
c10234cabdfd6eae47773fb6f163e0350fc797e1 82978 0 1 687749865 1 2 811016969 2 3 502155590 3 4 930576294 4 5 879987412 5 6 883450944 6 7 975772046 7 8 739249697 8 9 954502114 9 10 962223056 10 11 562948742 11 12 933819577 12 13 614418299 13 14 724040317 14 15 798630312 15 16 583709944 16 17 634442427 ...
output:
Unauthorized output
result:
Subtask #3:
score: 0
Wrong Answer
Test #34:
score: 14
Accepted
time: 1ms
memory: 7116kb
input:
c10234cabdfd6eae47773fb6f163e0350fc797e1 2 0 1 4
output:
064bde9ff69ddc34b3b45c2d26d58873d85290d3 OK 4 0
result:
ok 3 lines
Test #35:
score: 0
Wrong Answer
time: 0ms
memory: 6404kb
input:
c10234cabdfd6eae47773fb6f163e0350fc797e1 5 0 1 1 0 2 4 0 3 3 2 4 2
output:
064bde9ff69ddc34b3b45c2d26d58873d85290d3 OK 10 7 4 0 0
result:
wrong answer 3rd lines differ - expected: '10 5 1 0 0', found: '10 7 4 0 0'
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Time Limit Exceeded
Test #79:
score: 0
Time Limit Exceeded
input:
c10234cabdfd6eae47773fb6f163e0350fc797e1 96680 81008 32770 1 53103 75975 1 38090 49649 1 35805 25778 1 50058 68261 1 52213 58881 1 52672 34310 1 1080 42408 1 32306 82599 1 73623 7340 1 87691 42161 1 78365 96557 1 78654 88488 1 5875 25925 1 23217 85743 1 18698 42579 1 90401 84720 1 45973 91271 1 5282...
output:
Unauthorized output
result:
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%