제출 #362404

#제출 시각아이디문제언어결과실행 시간메모리
362404knightron0Traffic (IOI10_traffic)C++14
0 / 100
2 ms2668 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fr first #define sc second #define clr(a, x) memset(a, x, sizeof(a)) #define dbg(x) cout<<"("<<#x<<"): "<<x<<endl; #define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl; #define all(v) v.begin(), v.end() #define lcm(a, b) (a * b)/__gcd(a, b) #define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl; #define endl '\n' #define float long double const int MOD = 1e9 + 7; const int INF = 2e15; const int MAXN = 1e5 + 5; vector<int> adj[MAXN]; int value[MAXN]; int sz[MAXN] = {0}; int dfs(int s, int p){ int ans = value[s]; for(auto v: adj[s]){ if(v ==p) continue; ans += dfs(v, s); } sz[s] = ans; return ans; } int ans = INT_MAX; void dfs2(int s, int p, int last){ int mx = last; int sum = last; for(auto v: adj[s]){ if(v==p) continue; sum += sz[v]; mx = max(mx, sz[v]); } ans = min(ans, mx); for(auto v: adj[s]){ if(v==p) continue; int newlast = sum-sz[v]; newlast += value[s]; dfs2(v, s, newlast); } } int LocateCentre(int n, int p[], int d[], int s[]) { sz[0] = 0; value[0]= 0; for(int i= 0;i<n-1;i++){ d[i]++; s[i]++; adj[d[i]].pb(s[i]); adj[s[i]].pb(d[i]); } for(int i= 0;i<n;i++){ value[i+1] = p[i]; } dfs(1, -1); dfs2(1, 0, 0); cout<<ans<<endl; return 0; } // signed main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); // #ifdef LOCAL // freopen("input.txt", "r", stdin); // #endif // int n; // cin>>n; // int val[n]; // for(int i= 0;i<n;i++){ // cin>>val[i]; // } // int a[n], b[n]; // for(int i= 0;i<n-1;i++){ // cin>>a[i]>>b[i]; // } // LocateCentre(n, val, a, b); // return 0; // }

컴파일 시 표준 에러 (stderr) 메시지

traffic.cpp:17:17: warning: overflow in conversion from 'double' to 'int' changes value from '2.0e+15' to '2147483647' [-Woverflow]
   17 | const int INF = 2e15;
      |                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...