(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #205400

#제출 시각아이디문제언어결과실행 시간메모리
205400jasony123123Traffic (IOI10_traffic)C++11
100 / 100
1875 ms170872 KiB
#include "traffic.h" #include <bits/stdc++.h> //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/assoc_container.hpp> using namespace std; //using namespace __gnu_pbds; #define FOR(i,start,end) for(int i=start;i<(int)(end);i++) #define FORE(i,start,end) for(int i=start;i<=(int)end;i++) #define RFORE(i,start,end) for(int i = start; i>=end; i--) #define all(a) a.begin(), a.end() #define v vector typedef long long ll; typedef pair<int, int > pii; //template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T> void minn(T &a, T b) { a = min(a, b); } template<class T> void maxx(T &a, T b) { a = max(a, b); } v<int> adj[1000000]; ll sum[1000000]; pair<ll, int> ans = {LLONG_MAX, -1}; ll solve(int x, int p, int pp[], ll t){ ll mymax = 0; sum[x] = pp[x]; for(auto c : adj[x]) if(c!=p){ ll csum = solve(c,x,pp,t); maxx(mymax, csum); sum[x] += csum; } maxx(mymax, t-sum[x]); minn(ans, {mymax, x}); return sum[x]; } int LocateCentre(int N, int pp[], int S[], int D[]) { ll total = 0; FOR(i,0,N){ adj[S[i]].push_back(D[i]); adj[D[i]].push_back(S[i]); total += pp[i]; } solve(0,-1, pp, total); return ans.second; } /* 0-n-1 pp is number S-D */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...