답안 #918805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918805 2024-01-30T13:07:26 Z sunwukong123 Truck Driver (IOI23_deliveries) C++17
29 / 100
150 ms 10320 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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 7652 KB Output is correct
2 Correct 114 ms 7460 KB Output is correct
3 Correct 150 ms 7776 KB Output is correct
4 Correct 101 ms 10320 KB Output is correct
5 Correct 99 ms 10272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 9 ms 560 KB Output is correct
3 Correct 11 ms 472 KB Output is correct
4 Correct 14 ms 600 KB Output is correct
5 Correct 14 ms 600 KB Output is correct
6 Correct 15 ms 600 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 14 ms 600 KB Output is correct
9 Correct 14 ms 476 KB Output is correct
10 Correct 15 ms 604 KB Output is correct
11 Correct 11 ms 576 KB Output is correct
12 Correct 20 ms 344 KB Output is correct
13 Correct 19 ms 344 KB Output is correct
14 Correct 20 ms 348 KB Output is correct
15 Correct 19 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 7652 KB Output is correct
2 Correct 114 ms 7460 KB Output is correct
3 Correct 150 ms 7776 KB Output is correct
4 Correct 101 ms 10320 KB Output is correct
5 Correct 99 ms 10272 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 30 ms 604 KB Output is correct
8 Runtime error 8 ms 2140 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 7652 KB Output is correct
2 Correct 114 ms 7460 KB Output is correct
3 Correct 150 ms 7776 KB Output is correct
4 Correct 101 ms 10320 KB Output is correct
5 Correct 99 ms 10272 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 44 ms 600 KB Output is correct
8 Runtime error 8 ms 2136 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 7652 KB Output is correct
2 Correct 114 ms 7460 KB Output is correct
3 Correct 150 ms 7776 KB Output is correct
4 Correct 101 ms 10320 KB Output is correct
5 Correct 99 ms 10272 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 9 ms 560 KB Output is correct
8 Correct 11 ms 472 KB Output is correct
9 Correct 14 ms 600 KB Output is correct
10 Correct 14 ms 600 KB Output is correct
11 Correct 15 ms 600 KB Output is correct
12 Correct 13 ms 344 KB Output is correct
13 Correct 14 ms 600 KB Output is correct
14 Correct 14 ms 476 KB Output is correct
15 Correct 15 ms 604 KB Output is correct
16 Correct 11 ms 576 KB Output is correct
17 Correct 20 ms 344 KB Output is correct
18 Correct 19 ms 344 KB Output is correct
19 Correct 20 ms 348 KB Output is correct
20 Correct 19 ms 604 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 30 ms 604 KB Output is correct
23 Runtime error 8 ms 2140 KB Execution killed with signal 11
24 Halted 0 ms 0 KB -