(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.

Submission #312727

#TimeUsernameProblemLanguageResultExecution timeMemory
312727ronnithTraffic (IOI10_traffic)C++14
100 / 100
1472 ms149152 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) // #define int long long #define num(a) a-'0' #define charr(a) (a - 'A' + 1) #define rep(i,a,b) for(int i=a;i<b;i++) #define maxs(a,b) if(b>a)a=b #define mins(a,b) if(b<a)a=b #define bin1(a) __builtin_popcount(a) #define debug(x) cerr<<"["<<#x<<":"<<x<<"] " #define debug2(a,b) debug(a);debug(b) #define debug3(a,b,c) debug2(a,b);debug(c) #define de cerr #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*b)/(__gcd(a,b)) #define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define all(a) (a).begin(), (a).end() #define vi vector<long long> #define v vector #define p pair #define pii p<int,int> #define pb push_back #define mk make_pair #define f first #define s second #define ln "\n" typedef long double ld; typedef double d; using namespace std; using namespace __gnu_pbds; int modF=1e9+7; int inf=1e18+5; int nax = 1e6 + 5; vector<int> a(nax); vector<int> size(nax); vector<vector<int>> adj(nax); int ans = inf; int node = -1; void dfs1(int x,int pr){ // debug(x); size[x] = a[x]; for(auto e:adj[x]){ if(e != pr){ dfs1(e,x); size[x] += size[e]; } } } void dfs2(int x,int pr){ int mx = 0; for(auto e:adj[x]){ if(e != pr){ maxs(mx,size[e]); dfs2(e,x); } else{ maxs(mx,size[0] - size[x]); } } if(mx < ans){ ans = mx; node = x; } } int LocateCentre(int N,int P[],int S[],int D[]){ int res; int n = N; rep(i,0,n){ a[i] = P[i]; } rep(i,0,n - 1){ adj[S[i]].pb(D[i]); adj[D[i]].pb(S[i]); } // debug("yes"); dfs1(0,-1); dfs2(0,-1); // debug("yes"); res = node; return res; }

Compilation message (stderr)

traffic.cpp:35:13: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   35 | int inf=1e18+5;
      |         ~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...