Submission #917203

# Submission time Handle Problem Language Result Execution time Memory
917203 2024-01-27T12:34:56 Z zyq181 Truck Driver (IOI23_deliveries) C++17
0 / 100
2142 ms 2097152 KB
#include "deliveries.h"
#include <bits/stdc++.h>
using namespace std;

int N;
vector<pair<int, int> > adjList[1010];
int paredge[1010];
int sbtree[1010];
int tot;
int ans;
int w[1010];

void dfs(int n, int p = -1){
	sbtree[n]+=w[n];
	for(auto it: adjList[n]){
		int x, y;
		x = it.first;
		y = it.second;
		paredge[x] = y;
		dfs(x, n);
		sbtree[n] += sbtree[x];
	}
}



void init(int NN, std::vector<int> U, std::vector<int> V, std::vector<int> T, std::vector<int> W) {
	N = NN;
	for(int a=0; a<N-1; a++){
		adjList[U[a]].push_back({V[a], T[a]});
		adjList[V[a]].push_back({U[a], T[a]});
	}
	W[0]++;
	for(int a=0; a<N; a++){
		w[a] = W[a];
		tot += W[a];
	}
	return;
}

long long max_time(int S, int X) {
	for(int a=0; a<N; a++) sbtree[a] = 0;
	ans = 0;
	tot -= w[S];
	w[S] = X;
	if(S == 0) w[0]++;
	tot += w[S];
	dfs(0);
	for(int a=1; a<N; a++){
		if(tot/2 < sbtree[a]){
			ans += 2 * (tot - sbtree[a]) * paredge[a];
		}
		else{
			ans += 2 * sbtree[a] * paredge[a];
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 2142 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1383 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2142 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2142 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2142 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -