제출 #463690

#제출 시각아이디문제언어결과실행 시간메모리
463690KhizriTraffic (IOI10_traffic)C++17
100 / 100
1152 ms182468 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define F first #define S second #define INF 1e18 #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define pii pair<int,int> #define pll pair<ll,ll> #define OK cout<<"Ok"<<endl; #define MOD (ll)(1e9+7) #define endl "\n" const int mxn=1e6+5; int a[mxn],b[mxn],node,dis[mxn],len[mxn],SUM; vector<int>vt[mxn]; ll dfs(int u,int p,int sum,int arr[]){ int ans=0; for(int v:vt[u]){ if(v!=p){ int k=dfs(v,u,sum+arr[u],arr); dis[u]=max(dis[u],k); ans+=k; } } dis[u]=max(dis[u],SUM-ans-arr[u]); return ans+arr[u]; } int LocateCentre(int n, int arr[], int S[], int D[]) { for(int i=0;i<n;i++){ SUM+=arr[i]; } for(int i=0;i<n-1;i++){ vt[S[i]].pb(D[i]); vt[D[i]].pb(S[i]); } dfs(0,-1,0,arr); ll maxs=INF,ind; for(int i=0;i<n;i++){ if(dis[i]<maxs){ maxs=dis[i]; ind=i; } } return ind; }

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

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:47:9: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |  return ind;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...