Submission #918780

#TimeUsernameProblemLanguageResultExecution timeMemory
918780sunwukong123Truck Driver (IOI23_deliveries)C++17
0 / 100
91 ms10320 KiB
#include "deliveries.h" #include <bits/stdc++.h> using namespace std; #ifdef LOCAL void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) #else #define debug(...) #endif const int MAXN = 1005; const int inf=1000000500ll; const long long oo =1000000000000000500ll; const int MOD = (int)1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef pair<int,int> pi; vector<pi>adj[MAXN]; int n; int W[MAXN]; void init(int N, std::vector<int> U, std::vector<int> V, std::vector<int> T, std::vector<int> W) { n=N; for(int i=0;i<n-1;i++){ adj[U[i]].push_back({V[i],T[i]}); adj[V[i]].push_back({U[i],T[i]}); } for(int i=0;i<n;i++){ ::W[i]=W[i]; } W[0]+=1; } int sz[MAXN]; int res=0; void dfs(int x, int p, int vcost){ sz[x]+=W[x]; for(auto v:adj[x])if(v.first!=p){ dfs(v.first,x,v.second); sz[x]+=sz[v.first]; } } void get(int x, int p, int vcost){ for(auto v:adj[x])if(v.first!=p){ get(v.first,x,v.second); } debug(x,vcost,sz[x],sz[0]-sz[x]); res += vcost * 2 * min(sz[x],sz[0]-sz[x]); } int solve(){ memset(sz,0,sizeof sz); res=0; dfs(0,-1,0); get(0,-1,0); //exit(0); return res; } long long max_time(int S, int X) { W[S]=X; if(S==0){ W[S]++; } return solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...