Submission #918803

# Submission time Handle Problem Language Result Execution time Memory
918803 2024-01-30T13:05:12 Z sunwukong123 Truck Driver (IOI23_deliveries) C++17
0 / 100
106 ms 10064 KB
#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;
#define int long long
 
int W[MAXN];
void init(int32_t N, std::vector<int32_t> U, std::vector<int32_t> V, std::vector<int32_t> T, std::vector<int32_t> 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]++;
}
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);
	}
	res += vcost * 2ll * min(sz[x],sz[0]-sz[x]);
}
int solve(){
	memset(sz,0,sizeof sz);
	res=0;
	dfs(0,-1,0);
	get(0,-1,0);
	return res;
}
 
long long max_time(int32_t S, int32_t X) {
	W[S]=X;
	if(S==0){
		W[S]++;
	}
	return solve();
}
# Verdict Execution time Memory Grader output
1 Correct 106 ms 10064 KB Output is correct
2 Correct 103 ms 9808 KB Output is correct
3 Incorrect 104 ms 10064 KB 3rd lines differ - on the 1st token, expected: '86741232', found: '86741080'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB 3rd lines differ - on the 1st token, expected: '1627540', found: '1617480'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 106 ms 10064 KB Output is correct
2 Correct 103 ms 9808 KB Output is correct
3 Incorrect 104 ms 10064 KB 3rd lines differ - on the 1st token, expected: '86741232', found: '86741080'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 106 ms 10064 KB Output is correct
2 Correct 103 ms 9808 KB Output is correct
3 Incorrect 104 ms 10064 KB 3rd lines differ - on the 1st token, expected: '86741232', found: '86741080'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 106 ms 10064 KB Output is correct
2 Correct 103 ms 9808 KB Output is correct
3 Incorrect 104 ms 10064 KB 3rd lines differ - on the 1st token, expected: '86741232', found: '86741080'
4 Halted 0 ms 0 KB -